Java Code Examples for com.google.android.material.floatingactionbutton.FloatingActionButton#setOnClickListener()
The following examples show how to use
com.google.android.material.floatingactionbutton.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: IntroActivity.java From lrkFM with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_intro); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); final boolean permissionGranted = ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; FloatingActionButton fab = findViewById(R.id.fab); if (permissionGranted) { fab.setImageResource(R.drawable.ic_chevron_right_white_24dp); } fab.setOnClickListener(view -> { if (!permissionGranted && c <= 0) { FileActivity.verifyStoragePermissions(IntroActivity.this); fab.setImageResource(R.drawable.ic_chevron_right_white_24dp); c++; } else { launchMainAndFinish(savedInstanceState); } }); }
Example 2
Source File: HTMLActivity.java From shortyz with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); utils.holographic(this); utils.finishOnHomeButton(this); this.setContentView(R.layout.html_view); ActionBar actionBar = getSupportActionBar(); actionBar.hide(); WebView webview = (WebView) this.findViewById(R.id.webkit); Uri u = this.getIntent() .getData(); webview.loadUrl(u.toString()); FloatingActionButton download = (FloatingActionButton) this.findViewById(R.id.button_floating_action); if(download != null) { download.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); download.setImageBitmap(createBitmap("icons1.ttf", "k")); webview.setOnTouchListener(new ShowHideOnScroll(download)); } }
Example 3
Source File: AboutActivity.java From PocketMaps with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); CollapsingToolbarLayout toolBarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout); toolBarLayout.setTitle(getTitle()); 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(); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://github.com/junjunguo/PocketMaps/"))); } }); // set status bar // new SetStatusBarColor().setSystemBarColor(findViewById(R.id.statusBarBackgroundSettings), // getResources().getColor(R.color.my_primary_dark), this); }
Example 4
Source File: MainActivity.java From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 | 6 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) { Intent intent = new Intent(MainActivity.this, OrderActivity.class); intent.putExtra(EXTRA_MESSAGE, mOrderMessage); startActivity(intent); } }); PreferenceManager.setDefaultValues(this, R.xml.sync_preferences, false); PreferenceManager.setDefaultValues(this, R.xml.general_preferences, false); PreferenceManager.setDefaultValues(this, R.xml.notification_preferences, false); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); String marketPref = sharedPreferences.getString("sync_frequency", "-1"); displayToast(marketPref); }
Example 5
Source File: MainActivity.java From ssj with GNU General Public License v3.0 | 6 votes |
/** * Initialize floating action button to show/hide SSJ component selection buttons. */ private void initFloatingActionButton() { fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (actionButtonsVisible) { toggleActionButtons(false); } else { toggleActionButtons(true); } } }); }
Example 6
Source File: MainActivity.java From ArcNavigationView with Apache License 2.0 | 6 votes |
@Override protected void onCreate(@Nullable 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) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); drawer = findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); toggle.syncState(); NavigationView navigationView = findViewById(R.id.nav_view); NavigationView navigationViewRight = findViewById(R.id.nav_view_right); navigationViewRight.setNavigationItemSelectedListener(this); navigationView.setNavigationItemSelectedListener(this); }
Example 7
Source File: BubbleActivity.java From journaldev with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_bubble); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); textView = findViewById(R.id.textView); FloatingActionButton fab = 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 8
Source File: AdvanceDrawer4Activity.java From Drawer-Behavior with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_advance4); 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(); } }); drawer = (AdvanceDrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); drawer.setViewScale(Gravity.END, 0.9f); drawer.setViewElevation(Gravity.END, 20); }
Example 9
Source File: AdvanceDrawer2Activity.java From Drawer-Behavior with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_advance2); 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(); } }); drawer = (AdvanceDrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); drawer.setViewScale(Gravity.START, 0.9f); drawer.setViewElevation(Gravity.START, 20); }
Example 10
Source File: BaseMapDownload.java From trekarta with GNU General Public License v3.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); FloatingActionButton floatingButton = mFragmentHolder.enableActionButton(); floatingButton.setImageDrawable(getContext().getDrawable(R.drawable.ic_file_download)); floatingButton.setOnClickListener(v -> { mMapIndex.downloadBaseMap(); mFragmentHolder.disableActionButton(); mFragmentHolder.popCurrent(); }); }
Example 11
Source File: FlagSevenSqliteActivity.java From InjuredAndroid with Apache License 2.0 | 5 votes |
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_flag_seven_sqlite); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); FloatingActionButton fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (click == 0) { Snackbar.make(view, "Run ADB as root.", Snackbar.LENGTH_LONG) .setAction("Action",null).show(); click = click + 1; } else if (click == 1) { Snackbar.make(view, "Stay on this activity.", Snackbar.LENGTH_LONG) .setAction("Action",null).show(); click = 0; } else if (click == 2) { Snackbar.make(view, "Not all encodings are the same, some need to be rotated.", Snackbar.LENGTH_LONG) .setAction("Action",null).show(); } } }); SQLiteDatabase db = this.dbHelper.getWritableDatabase(); ContentValues values = new ContentValues(); byte[] decode = Base64.decode("VGhlIGZsYWcgaGFzaCE=", 0); String str = Add.COLUMN_NAME_TITLE; values.put(str, decode); byte[] decode2 = Base64.decode("MmFiOTYzOTBjN2RiZTM0MzlkZTc0ZDBjOWIwYjE3Njc=", 0); String str2 = Add.COLUMN_NAME_SUBTITLE; values.put(str2, decode2); String str3 = Add.TABLE_NAME; db.insert(str3, null, values); values.put(str, Base64.decode("VGhlIGZsYWcgaXMgYWxzbyBhIHBhc3N3b3JkIQ==", 0)); values.put(str2, Hide.getRemoteUrl()); db.insert(str3, null, values); }
Example 12
Source File: DefaultDrawerActivity.java From Drawer-Behavior with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_default); 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(); } }); drawer = (AdvanceDrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); }
Example 13
Source File: CrashReport.java From trekarta with GNU General Public License v3.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); FloatingActionButton floatingButton = mFragmentHolder.enableActionButton(); floatingButton.setImageDrawable(getContext().getDrawable(R.drawable.ic_send)); floatingButton.setOnClickListener(v -> { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"}); File file = MapTrek.getApplication().getExceptionLog(); intent.putExtra(Intent.EXTRA_STREAM, ExportProvider.getUriForFile(getContext(), file)); intent.setType("vnd.android.cursor.dir/email"); intent.putExtra(Intent.EXTRA_SUBJECT, "MapTrek crash report"); StringBuilder text = new StringBuilder(); text.append("Device : ").append(Build.DEVICE); text.append("\nBrand : ").append(Build.BRAND); text.append("\nModel : ").append(Build.MODEL); text.append("\nProduct : ").append(Build.PRODUCT); text.append("\nLocale : ").append(Locale.getDefault().toString()); text.append("\nBuild : ").append(Build.DISPLAY); text.append("\nVersion : ").append(Build.VERSION.RELEASE); try { PackageInfo info = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0); if (info != null) { text.append("\nApk Version : ").append(info.versionCode).append(" ").append(info.versionName); } } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } intent.putExtra(Intent.EXTRA_TEXT, text.toString()); startActivity(Intent.createChooser(intent, getString(R.string.send_crash_report))); mFragmentHolder.disableActionButton(); mFragmentHolder.popCurrent(); }); }
Example 14
Source File: FilesActivity.java From dropbox-sdk-java with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String path = getIntent().getStringExtra(EXTRA_PATH); mPath = path == null ? "" : path; setContentView(R.layout.activity_files); Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar); setSupportActionBar(toolbar); FloatingActionButton fab = (FloatingActionButton)findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { performWithPermissions(FileAction.UPLOAD); } }); //init picaso client PicassoClient.init(this,DropboxClientFactory.getClient()); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.files_list); mFilesAdapter = new FilesAdapter(PicassoClient.getPicasso(), new FilesAdapter.Callback() { @Override public void onFolderClicked(FolderMetadata folder) { startActivity(FilesActivity.getIntent(FilesActivity.this, folder.getPathLower())); } @Override public void onFileClicked(final FileMetadata file) { mSelectedFile = file; performWithPermissions(FileAction.DOWNLOAD); } }); recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.setAdapter(mFilesAdapter); mSelectedFile = null; }
Example 15
Source File: FlagEightLoginActivity.java From InjuredAndroid with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_flag_eight_login); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); FirebaseAuth mAuth; mAuth = FirebaseAuth.getInstance(); mAuth.signInAnonymously() .addOnCompleteListener(this, task -> { if (task.isSuccessful()) { // Sign in success, update UI with the signed-in user's information Log.d(TAG, "signInAnonymously:success"); } else { // If sign in fails, display a message to the user. Log.w(TAG, "signInAnonymously:failure", task.getException()); Toast.makeText(FlagEightLoginActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } }); FloatingActionButton fab = findViewById(R.id.fab); fab.setOnClickListener(view -> { if (click == 0) { Snackbar.make(view, "AWS CLI.", Snackbar.LENGTH_LONG) .setAction("Action",null).show(); click = click + 1; } else if (click == 1) { Snackbar.make(view, "AWS profiles and credentials.", Snackbar.LENGTH_LONG) .setAction("Action",null).show(); click = 0; } }); }
Example 16
Source File: MainActivity.java From UploadToJitpack with Apache License 2.0 | 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) { Snackbar.make(view, AwesomeLib.getInstance().makeAwesome("Nishant"), Snackbar.LENGTH_LONG) .setAction("Action", null) .show(); } }); }
Example 17
Source File: MessageListActivity.java From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 | 5 votes |
private void initFab() { FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); if (fab == null) { return; } fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ARouter.getInstance().build(ARouterConstants.ACTIVITY_MESSAGE_POST) .withString("action", "new") .navigation(MessageListActivity.this); } }); }
Example 18
Source File: AdvanceDrawer1Activity.java From Drawer-Behavior with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_advance1); 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(); } }); drawer = (AdvanceDrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); drawer.useCustomBehavior(Gravity.START); drawer.useCustomBehavior(Gravity.END); }
Example 19
Source File: PluginsActivity.java From MHViewer with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); data = MHPluginManager.Companion.getINSTANCE().plugins(); setContentView(R.layout.activity_plugins); setNavigationIcon(R.drawable.v_arrow_left_dark_x24); recyclerView = findViewById(R.id.recycler_view); tip = findViewById(R.id.tip); FloatingActionButton fab = findViewById(R.id.fab); adapter = new PluginsAdapter(); recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false)); LinearDividerItemDecoration decoration = new LinearDividerItemDecoration( LinearDividerItemDecoration.VERTICAL, AttrResources.getAttrColor(this, R.attr.dividerColor), LayoutUtils.dp2pix(this, 1)); decoration.setShowLastDivider(true); recyclerView.addItemDecoration(decoration); recyclerView.setSelector(Ripple.generateRippleDrawable(this, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT))); recyclerView.setHasFixedSize(true); recyclerView.setOnItemClickListener(this); recyclerView.setPadding( recyclerView.getPaddingLeft(), recyclerView.getPaddingTop(), recyclerView.getPaddingRight(), recyclerView.getPaddingBottom() + getResources().getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab)); fab.setOnClickListener(this); recyclerView.setVisibility(data.isEmpty() ? View.GONE : View.VISIBLE); tip.setVisibility(data.isEmpty() ? View.VISIBLE : View.GONE); }
Example 20
Source File: PostItemDetailActivity.java From mimi-reader with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_postitem_detail); final Toolbar toolbar = (Toolbar) findViewById(R.id.mimi_toolbar); if (toolbar != null) { toolbar.setNavigationOnClickListener(this); // toolbar.setSubtitleTextColor(getResources().getColor(R.color.toolbar_subtitle_color)); setToolbar(toolbar); } appBarLayout = (AppBarLayout) findViewById(R.id.appbar); addContentFab = (FloatingActionButton) findViewById(R.id.fab_add_content); addContentFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (threadFragment instanceof ContentInterface) { ((ContentInterface) threadFragment).addContent(); } } }); final Bundle extras = getIntent().getExtras(); if (extras != null) { if (extras.containsKey(Extras.EXTRAS_BOARD_NAME)) { boardName = extras.getString(Extras.EXTRAS_BOARD_NAME); } int position = -1; if (extras.containsKey(Extras.EXTRAS_POSITION)) { position = extras.getInt(Extras.EXTRAS_POSITION, -1); } if (extras.containsKey(Extras.EXTRAS_BOARD_TITLE)) { setTitle(extras.getString(Extras.EXTRAS_BOARD_TITLE)); } if (extras.containsKey(Extras.EXTRAS_FROM_URL)) { fromUrl = true; } if (!extras.containsKey(Extras.EXTRAS_THREAD_LIST)) { if (position >= 0) { ArrayList<ThreadInfo> threadList = getIntent().getParcelableArrayListExtra(Extras.EXTRAS_THREAD_LIST); if (threadList != null && !TextUtils.isEmpty(threadList.get(position).boardTitle)) { setTitle(threadList.get(position).boardTitle); } } singleThread = true; } } // setAdContainer(R.id.advert_container, MimiUtil.adsEnabled(this)); initDrawers(R.id.nav_drawer, R.id.nav_drawer_container, false); createDrawers(R.id.nav_drawer); // savedInstanceState is non-null when there is fragment state // saved from previous configurations of this activity // (e.g. when rotating the screen from portrait to landscape). // In this case, the fragment will automatically be re-added // to its container so we don't need to manually add it. // For more information, see the Fragments API guide at: // // http://developer.android.com/guide/components/fragments.html // if (savedInstanceState == null) { // Create the detail fragment and add it to the activity // using a fragment transaction. final Bundle arguments = getIntent().getExtras(); if (singleThread) { threadFragment = new ThreadDetailFragment(); } else { threadFragment = new ThreadPagerFragment(); } threadFragment.setArguments(arguments); getSupportFragmentManager().beginTransaction() .add(R.id.postitem_detail_container, threadFragment, POST_DETAIL_FRAGMENT_TAG) .commit(); } else { threadFragment = (MimiFragmentBase) getSupportFragmentManager().findFragmentByTag(POST_DETAIL_FRAGMENT_TAG); } }