Java Code Examples for android.support.design.widget.FloatingActionButton#setOnClickListener()
The following examples show how to use
android.support.design.widget.FloatingActionButton#setOnClickListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From A-week-to-develop-android-app-plan with Apache License 2.0 | 7 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); 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) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); }
Example 2
Source File: MainActivity.java From SwipeStack with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSwipeStack = (SwipeStack) findViewById(R.id.swipeStack); mButtonLeft = (Button) findViewById(R.id.buttonSwipeLeft); mButtonRight = (Button) findViewById(R.id.buttonSwipeRight); mFab = (FloatingActionButton) findViewById(R.id.fabAdd); mButtonLeft.setOnClickListener(this); mButtonRight.setOnClickListener(this); mFab.setOnClickListener(this); mData = new ArrayList<>(); mAdapter = new SwipeStackAdapter(mData); mSwipeStack.setAdapter(mAdapter); mSwipeStack.setListener(this); fillWithTestData(); }
Example 3
Source File: CartActivity.java From android-instant-apps-demo with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cart); viewModel = ViewModelProviders.of(this).get(CartViewModel.class); fab = (FloatingActionButton) findViewById(R.id.fab); toolbar = (Toolbar) findViewById(R.id.toolbar); setupToolbar(); handleDeepLink(); fab.setImageDrawable(VectorDrawableCompat.create(getResources(), R.drawable.ic_share_white_24dp, null)); fab.setOnClickListener(view -> { String cartId = viewModel.getCartId().getValue(); ShareCompat.IntentBuilder.from(this) .setText(String.format(Locale.US, "Check out my shopping cart now using Android Instant Apps! \n%s/cart/%s", ROOT_ENDPOINT, cartId)) .setType("text/plain") .setChooserTitle(share_cart) .startChooser(); }); }
Example 4
Source File: UpdateDemoActivity.java From atlas with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scrolling); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ((TextView)findViewById(R.id.tv_guide)).setText(getString(R.string.update_step)); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(view -> { // Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) // .setAction("Action", null).show(); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... voids) { // Updater.update(getBaseContext()); return null; } @Override protected void onPostExecute(Void aVoid) { android.os.Process.killProcess(android.os.Process.myPid()); } }.execute(); }); }
Example 5
Source File: TestActivity.java From Woocommerce-Android-Client with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test); 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) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); getSupportActionBar().setDisplayHomeAsUpEnabled(true); init(); }
Example 6
Source File: AddNoteFragment.java From androidtestdebug with MIT License | 6 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mActionListener = new AddNotePresenter(Injection.provideNotesRepository(), this, Injection.provideImageFile()); FloatingActionButton fab = (FloatingActionButton) getActivity().findViewById(R.id.fab_add_notes); fab.setImageResource(R.drawable.ic_done); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mActionListener.saveNote(mTitle.getText().toString(), mDescription.getText().toString()); } }); }
Example 7
Source File: MainActivity.java From journaldev with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FloatingActionButton fabSync = findViewById(R.id.fabSync); FloatingActionButton fabTickCross = findViewById(R.id.fabTickCross); tickToCross = (AnimatedVectorDrawable) getDrawable(R.drawable.avd_tick2cross); crossToTick = (AnimatedVectorDrawable) getDrawable(R.drawable.avd_cross2tick); ImageView imgSettings = findViewById(R.id.imgSettings); ImageView imgJD = findViewById(R.id.imgJD); imgSettings.setOnClickListener(this); imgJD.setOnClickListener(this); AnimatedVectorDrawableCompat animatedVectorDrawableCompat = AnimatedVectorDrawableCompat.create(this, R.drawable.avd_sync); fabSync.setImageDrawable(animatedVectorDrawableCompat); fabSync.setOnClickListener(this); fabTickCross.setOnClickListener(this); }
Example 8
Source File: FabSpeedDial.java From FireFiles with Apache License 2.0 | 6 votes |
private void setupFab() { // Set up the client's FAB fab = (FloatingActionButton) findViewById(R.id.fab); fab.setImageDrawable(fabDrawable); if (Utils.hasLollipop()) { fab.setImageTintList(fabDrawableTint); } if (fabBackgroundTint != null) { fab.setBackgroundTintList(fabBackgroundTint); } fab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (isAnimating) return; if (isMenuOpen()) { closeMenu(); } else { openMenu(); } } }); }
Example 9
Source File: NotesFragment.java From multi-copy with Apache License 2.0 | 6 votes |
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_notes, container, false); fabNewNote = (FloatingActionButton) root.findViewById(R.id.fabNewNote); recyclerView = (RecyclerView) root.findViewById(R.id.rvNotesList); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext()); notesList = new ArrayList<>(); if (notesFragment_LOG) Log.d(TAG, "onCreateView: " + notesList.toString()); notesAdapter = new NotesAdapter(notesList,getContext()); recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setAdapter(notesAdapter); recyclerView.setItemAnimator(new DefaultItemAnimator()); fabNewNote.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(getActivity(),NewNoteActivity.class); startActivityForResult(i,Constants.NEW_NOTE_ACTIVTY_KEY); } }); refreshData(); implementREcyclerViewClickListener(); return root; }
Example 10
Source File: SheetSongListController.java From Musicoco with Apache License 2.0 | 5 votes |
public void initViews() { random = (ImageView) activity.findViewById(R.id.sheet_detail_songs_icon); playAllRandom = (TextView) activity.findViewById(R.id.sheet_detail_songs_play_random); line = activity.findViewById(R.id.sheet_detail_songs_line); songList = (RecyclerView) activity.findViewById(R.id.sheet_detail_songs_list); randomContainer = activity.findViewById(R.id.sheet_detail_random_container); sortTip = (TextView) activity.findViewById(R.id.sheet_detail_songs_sort_tip); checkContainer = activity.findViewById(R.id.sheet_detail_check_container); checkAll = (CheckBox) activity.findViewById(R.id.sheet_detail_check_all); checkCount = (TextView) activity.findViewById(R.id.sheet_detail_check_count); checkAll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { boolean isChecked = checkAll.isChecked(); if (isChecked) { songAdapter.checkAll(); } else { songAdapter.clearAllCheck(); } } }); randomContainer.setOnClickListener(this); FloatingActionButton fabPlayAll = (FloatingActionButton) activity.findViewById(R.id.sheet_detail_play_all); fabPlayAll.setOnClickListener(this); songList.post(new Runnable() { @Override public void run() { calculateRecycleViewHeight(); } }); }
Example 11
Source File: MainActivity.java From AndroidPlayground with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); 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) { doTest(); } }); }
Example 12
Source File: AlbumFragment.java From AlbumSelector with Apache License 2.0 | 5 votes |
private void initViews(View rootView) { mRvImageGrid = (RecyclerView) rootView.findViewById(R.id.rv_image_grid); mRvFolderList = (RecyclerView) rootView.findViewById(R.id.rv_album_list); mFab = (FloatingActionButton) rootView.findViewById(R.id.fab); mOverlay = rootView.findViewById(R.id.overlay); mEmptyView = rootView.findViewById(R.id.rl_no_image); initRecyclerView(); mFab.setOnClickListener(this); mOverlay.setOnClickListener(this); }
Example 13
Source File: MainActivity.java From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); FloatingActionButton fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { int wordListSize = mWordList.size(); // add new word to the linked list mWordList.addLast("+ Word " + wordListSize); // notify adapter of data change Objects.requireNonNull(mRecyclerView.getAdapter()).notifyItemInserted(wordListSize); // scroll to the bottom of the list mRecyclerView.smoothScrollToPosition(wordListSize); } }); // populate the initial data for (int i = 1; i < 21; i++) { mWordList.add("Word " + i); } // set up recyclerView - find view, create and set adapter; set layout manager mRecyclerView = findViewById(R.id.recyclerView); WordListAdapter mAdapter = new WordListAdapter(this, mWordList); mRecyclerView.setAdapter(mAdapter); mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); }
Example 14
Source File: Food_RecyclerView_Main.java From Stayfit with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.activity_recyclerview_activity, container, false); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.cardList); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mRecyclerView.setLayoutManager(mLayoutManager); mRecyclerViewAdapter = new Food_MyRecyclerViewAdapter(getActivity(), foodData.foodList); mRecyclerView.setAdapter(mRecyclerViewAdapter); // Animation mRecyclerView.setItemAnimator(new ScaleInBottomAnimator()); mRecyclerView.getItemAnimator().setAddDuration(100); mRecyclerView.getItemAnimator().setRemoveDuration(1000); mRecyclerView.getItemAnimator().setMoveDuration(100); mRecyclerView.getItemAnimator().setChangeDuration(100); ScaleInBottomAnimator animator = new ScaleInBottomAnimator(); mRecyclerView.setItemAnimator(animator); // Adapter Animation mRecyclerView.setAdapter(new ScaleInAnimationAdapter(mRecyclerViewAdapter)); ScaleInAnimationAdapter alphaAdapter = new ScaleInAnimationAdapter(mRecyclerViewAdapter); alphaAdapter.setDuration(500); mRecyclerView.setAdapter(alphaAdapter); voice = (FloatingActionButton) rootView.findViewById(R.id.vsfb); voice.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { promptSpeechInput(); } }); return rootView; }
Example 15
Source File: ShowCaptureActivity.java From SnapchatClone with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_show_capture); final byte[] img = CameraFragment.imageByte; try { bitmap = BitmapFactory.decodeByteArray(img, 0, img.length); } catch (Exception e) { e.printStackTrace(); finish(); } ImageView imgView = findViewById(R.id.imageViewCapturedImageShowCapture); imgView.setImageBitmap(bitmap); Uid = FirebaseAuth.getInstance().getUid(); FloatingActionButton mSend = findViewById(R.id.buttonStorySend); mSend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(getApplicationContext(), ChooseReceiverActivity.class); startActivity(intent); } }); }
Example 16
Source File: AddEditHiveFragment.java From go-bees with GNU General Public License v3.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Configure floating action button FloatingActionButton fab = (FloatingActionButton) getActivity().findViewById(R.id.fab_add_hive); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { presenter.save(nameTextView.getText().toString(), notesTextView.getText().toString()); } }); }
Example 17
Source File: DeviceScanActivity.java From BleSensorTag with MIT License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.title_devices); setContentView(R.layout.device_scan_activity); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); emptyView = findViewById(android.R.id.empty); progress = findViewById(android.R.id.progress); listView = (ListView) findViewById(android.R.id.list); listView.setEmptyView(emptyView); listView.setOnItemClickListener(this); fab = (FloatingActionButton) findViewById(R.id.scan_fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { if (scanner == null) { return; } setScanActive(!scanner.isScanning()); } }); final int bleStatus = BleUtils.getBleStatus(getBaseContext()); switch (bleStatus) { case BleUtils.STATUS_BLE_NOT_AVAILABLE: ErrorDialog.newInstance(R.string.dialog_error_no_ble) .show(getFragmentManager(), ErrorDialog.TAG); return; case BleUtils.STATUS_BLUETOOTH_NOT_AVAILABLE: ErrorDialog.newInstance(R.string.dialog_error_no_bluetooth) .show(getFragmentManager(), ErrorDialog.TAG); return; default: bluetoothAdapter = BleUtils.getBluetoothAdapter(getBaseContext()); } if (bluetoothAdapter == null) { return; } // initialize scanner scanner = new BleScanner(bluetoothAdapter, new ScanProcessor()); scanner.setScanPeriod(SCAN_PERIOD); }
Example 18
Source File: FirstActivity.java From ActSwitchAnimTool with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_first); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mActSwitchDemoBtn = (FloatingActionButton) findViewById(R.id.fab); initTool(); //DEMO FIRST. mActSwitchDemoBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); mFirstDemoActSwitchAnimTool.setAnimType(0).build(); } }); //DEMO SECOND. mShareViewDemoBtn = (FloatingActionButton) findViewById(R.id.share_float_btn); final ActSwitchAnimTool shareDemoTool = new ActSwitchAnimTool(FirstActivity.this) .target(mShareViewDemoBtn) .setmColorStart(Color.parseColor("#33D1FF")) .setmColorEnd(Color.parseColor("#33D1FF")); mShareContainer = new ShareContainer(FirstActivity.this); mShareContainer.setIShareCallback(new ShareContainer.IShareCallback() { @Override public void onCancel() { mShareContainer.hideShareBtn(); shareDemoTool.setAnimType(ActSwitchAnimTool.MODE_SHRINK) .removeContainerView(mShareContainer) .build(); } }); mShareViewDemoBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { shareDemoTool.setAnimType(ActSwitchAnimTool.MODE_SPREAD) .addContainerView(mShareContainer, new ActSwitchAnimTool.SwitchAnimCallback() { @Override public void onAnimationStart() { } @Override public void onAnimationEnd() { mShareContainer.showShareBtn(); } @Override public void onAnimationUpdate(int progress) { } }). build(); } }); }
Example 19
Source File: ConfigureCallDialogPage1ContactsFragment.java From PowerSwitch_Android with GNU General Public License v3.0 | 4 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.dialog_fragment_configure_call_page_1, container, false); broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (LocalBroadcastConstants.INTENT_CALL_PHONE_NUMBER_ADDED.equals(intent.getAction())) { ArrayList<String> newPhoneNumbers = intent.getStringArrayListExtra(AddPhoneNumberDialog.KEY_PHONE_NUMBER); for (String number : newPhoneNumbers) { if (!phoneNumbers.contains(number)) { phoneNumbers.add(number); } } phoneNumberRecyclerViewAdapter.notifyDataSetChanged(); } } }; recyclerViewContacts = (RecyclerView) rootView.findViewById(R.id.recyclerView_contacts); phoneNumberRecyclerViewAdapter = new PhoneNumberRecyclerViewAdapter(getActivity(), phoneNumbers); recyclerViewContacts.setAdapter(phoneNumberRecyclerViewAdapter); phoneNumberRecyclerViewAdapter.setOnDeleteClickListener(new PhoneNumberRecyclerViewAdapter.OnItemClickListener() { @Override public void onItemClick(View itemView, final int position) { new AlertDialog.Builder(getContext()) .setTitle(R.string.delete) .setMessage(R.string.are_you_sure) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { phoneNumbers.remove(position); phoneNumberRecyclerViewAdapter.notifyDataSetChanged(); notifyConfigurationChanged(); } catch (Exception e) { StatusMessageHandler.showErrorMessage(getActivity(), e); } } }) .setNeutralButton(android.R.string.cancel, null) .show(); } }); StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL); recyclerViewContacts.setLayoutManager(layoutManager); final FloatingActionButton addContactFAB = (FloatingActionButton) rootView.findViewById(R.id.add_contact_fab); addContactFAB.setImageDrawable(IconicsHelper.getAddIcon(getActivity(), ContextCompat.getColor(getActivity(), android.R.color.white))); final Fragment fragment = this; addContactFAB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AddPhoneNumberDialog addPhoneNumberDialog = new AddPhoneNumberDialog(); addPhoneNumberDialog.setTargetFragment(fragment, 0); addPhoneNumberDialog.show(getFragmentManager(), null); } }); Bundle args = getArguments(); if (args != null && args.containsKey(ConfigureCallEventDialog.CALL_EVENT_ID_KEY)) { callEventId = args.getLong(ConfigureCallEventDialog.CALL_EVENT_ID_KEY); initializeCallData(callEventId); } return rootView; }
Example 20
Source File: FabSpeedDial.java From fab-speed-dial with Apache License 2.0 | 4 votes |
private View createFabMenuItem(MenuItem menuItem) { ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext()) .inflate(getMenuItemLayoutId(), this, false); FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab); CardView cardView = (CardView) fabMenuItem.findViewById(R.id.card_view); TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view); fabMenuItemMap.put(miniFab, menuItem); cardViewMenuItemMap.put(cardView, menuItem); miniFab.setImageDrawable(menuItem.getIcon()); miniFab.setOnClickListener(this); cardView.setOnClickListener(this); ViewCompat.setAlpha(miniFab, 0f); ViewCompat.setAlpha(cardView, 0f); final CharSequence title = menuItem.getTitle(); if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) { cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor()); titleView.setText(title); titleView.setTypeface(null, Typeface.BOLD); titleView.setTextColor(miniFabTitleTextColor); if (miniFabTitleTextColorArray != null) { titleView.setTextColor(ContextCompat.getColorStateList(getContext(), miniFabTitleTextColorArray[menuItem.getOrder()])); } } else { fabMenuItem.removeView(cardView); } miniFab.setBackgroundTintList(miniFabBackgroundTint); if (miniFabBackgroundTintArray != null) { miniFab.setBackgroundTintList(ContextCompat.getColorStateList(getContext(), miniFabBackgroundTintArray[menuItem.getOrder()])); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { miniFab.setImageTintList(miniFabDrawableTint); } return fabMenuItem; }