use of android.support.design.widget.FloatingActionButton in project Synthese_2BIN by TheYoungSensei.
the class ItemDetailActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_detail);
Toolbar toolbar = (Toolbar) findViewById(R.id.detail_toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own detail action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
});
// Show the Up button in the action bar.
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
//
if (savedInstanceState == null) {
// Create the detail fragment and add it to the activity
// using a fragment transaction.
Bundle arguments = new Bundle();
arguments.putString(ItemDetailFragment.ARG_ITEM_ID, getIntent().getStringExtra(ItemDetailFragment.ARG_ITEM_ID));
ItemDetailFragment fragment = new ItemDetailFragment();
fragment.setArguments(arguments);
getSupportFragmentManager().beginTransaction().add(R.id.item_detail_container, fragment).commit();
}
}
use of android.support.design.widget.FloatingActionButton in project MadMax by deviz92.
the class DetailFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// create the view to return
View mainView = null;
// get the bundle
Bundle bundle = this.getArguments();
// the listener will be the GroupDetailActivity or the FriendDetailActivity
setInterface((OnItemClickInterface) getActivity());
databaseReference = FirebaseDatabase.getInstance().getReference();
// when an item in the list will be clicked the onListItemClicked will be called
groupsViewAdapter = new GroupsViewAdapter(this.getContext(), this, groups, DetailFragment.TAG);
if (activityName.equals("FriendDetailActivity")) {
Log.d(TAG, "FriendDetailActivity per RecylerView");
// Inflate the layout for this fragment
mainView = inflater.inflate(R.layout.skeleton_list_friend, container, false);
RecyclerView.ItemDecoration divider = new InsetDivider.Builder(getContext()).orientation(InsetDivider.VERTICAL_LIST).dividerHeight(getResources().getDimensionPixelSize(R.dimen.divider_height)).color(ContextCompat.getColor(getContext(), R.color.colorDivider)).insets(getResources().getDimensionPixelSize(R.dimen.divider_inset), 0).overlay(true).build();
recyclerView = (RecyclerView) mainView.findViewById(R.id.rv_skeleton);
layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(divider);
recyclerView.setAdapter(groupsViewAdapter);
// Extract data from bundle
friendID = bundle.getString("friendID");
// Show shared groups
databaseReference.child("users").child(MainActivity.getCurrentUser().getID()).child("friends").child(friendID).child("sharedGroups").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot sharedGroupSnapshot : dataSnapshot.getChildren()) {
FirebaseUtils.getInstance().getGroup(sharedGroupSnapshot.getKey(), groups, groupsViewAdapter);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
} else if (activityName.equals("GroupDetailActivity")) {
groupID = bundle.getString("groupID");
mainView = inflater.inflate(R.layout.fragment_group_detail, container, false);
fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
fab.setImageResource(android.R.drawable.ic_input_add);
TabLayout tabLayout = (TabLayout) mainView.findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText(R.string.expenses));
tabLayout.addTab(tabLayout.newTab().setText(R.string.members));
tabLayout.addTab(tabLayout.newTab().setText(R.string.activities));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
updateFab(0);
final ViewPager viewPager = (ViewPager) mainView.findViewById(R.id.main_view_pager);
final DetailFragment.PagerAdapter adapter = new DetailFragment.PagerAdapter(getActivity().getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
Log.d(TAG, "selected tab " + tab.getPosition());
updateFab(tab.getPosition());
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
return mainView;
}
use of android.support.design.widget.FloatingActionButton in project J2ME-Loader by nikita36078.
the class AppsListFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
registerForContextMenu(getListView());
FloatingActionButton fab = getActivity().findViewById(R.id.fab);
fab.setOnClickListener(v -> {
Intent i = new Intent(getActivity(), FilteredFilePickerActivity.class);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
i.putExtra(FilePickerActivity.EXTRA_SINGLE_CLICK, true);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false);
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_FILE);
i.putExtra(FilePickerActivity.EXTRA_START_PATH, FilteredFilePickerFragment.getLastPath());
startActivityForResult(i, FILE_CODE);
});
}
use of android.support.design.widget.FloatingActionButton in project SherlockAdapter by EvilBT.
the class MultiSelectItemActivity method onCreate.
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.act_multi_select_item);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getSelectedList();
}
});
findViewById(R.id.selectAll).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 全选
adapter.selectAll();
}
});
findViewById(R.id.unselectAll).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 全不选
adapter.clearSelectAll();
}
});
adapter = new MyMultiSelectAdapter();
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
recyclerView.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL));
recyclerView.setAdapter(adapter);
// 屏障默认的Change动画,默认的Change动画会闪烁一下
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
adapter.setOnItemCheckedChangeListener(new OnItemCheckedChangeListener() {
@Override
public void onItemCheck(@NonNull View view, boolean isChecked, int adapterPosition) {
final int id = view.getId();
if (id == R.id.checkbox) {
IMultiSelectItem selectorItem = adapter.getData(adapterPosition);
if (selectorItem != null) {
final int selectedSize = adapter.getSelectedItems().size();
if (isChecked && selectedSize > 9) {
Toast.makeText(MultiSelectItemActivity.this, "您最多只能选择9个", Toast.LENGTH_SHORT).show();
selectorItem.setChecked(false);
adapter.notifyItemChanged(adapterPosition);
}
}
}
}
});
List<IMultiSelectItem> data = new ArrayList<>(20);
for (int i = 0; i < 40; i++) {
SelectorCard card = new SelectorCard(i);
data.add(card);
}
// 添加一个不可选中的数据在列表上
NoSelectCard card = new NoSelectCard("我跟他们不一样");
data.add(0, card);
adapter.setData(data);
}
Aggregations