private void setUpActionButtons() { actionButtonLayout = (RelativeLayout) findViewById(R.id.action_button_layout); final FloatingActionsMenu actionMenu = (FloatingActionsMenu) findViewById(R.id.add_action_menu); final FloatingActionButton manuallyAddButton = (FloatingActionButton) findViewById(R.id.add_action_button_manually); final FloatingActionButton scanButton = (FloatingActionButton) findViewById(R.id.add_action_button_scan); actionMenu.setOnFloatingActionsMenuUpdateListener( new FloatingActionsMenu.OnFloatingActionsMenuUpdateListener() { @Override public void onMenuExpanded() { dimBackgroundAsAnimation(actionButtonLayout); actionButtonLayout.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { actionMenu.collapse(); } }); } @Override public void onMenuCollapsed() { actionButtonLayout.setBackgroundColor( getResources().getColor(android.R.color.transparent)); actionButtonLayout.setOnClickListener(null); actionButtonLayout.setClickable(false); } }); manuallyAddButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View view) { EvercamPlayApplication.sendEventAnalytics( CamerasActivity.this, R.string.category_menu, R.string.action_add_camera, R.string.label_add_camera_manually); startActivityForResult( new Intent(CamerasActivity.this, AddEditCameraActivity.class), Constants.REQUEST_CODE_ADD_CAMERA); actionMenu.collapse(); } }); scanButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { EvercamPlayApplication.sendEventAnalytics( CamerasActivity.this, R.string.category_menu, R.string.action_add_camera, R.string.label_add_camera_scan); startActivityForResult( new Intent(CamerasActivity.this, ScanActivity.class), Constants.REQUEST_CODE_ADD_CAMERA); actionMenu.collapse(); } }); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_item, container, false); // Set the adapter if (mAdapter != null) { if (isNewData()) { createNewAdapter(); } mListView = (AbsListView) view.findViewById(android.R.id.list); mListView.setAdapter(mAdapter); // Set OnItemClickListener so we can be notified on item clicks mListView.setOnItemClickListener(this); } else { TextView noRestaurantView = (TextView) view.findViewById(R.id.noRestaurantView); noRestaurantView.setText("There aren't any restaurants."); } FloatingActionButton addRestaurantButton = (FloatingActionButton) view.findViewById(R.id.addRestaurant); addRestaurantButton.setOnClickListener(this); mListener = (OnFragmentInteractionListener) getActivity(); return view; }
@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(); } }); com.getbase.floatingactionbutton.FloatingActionButton one = (com.getbase.floatingactionbutton.FloatingActionButton) findViewById(R.id.one); com.getbase.floatingactionbutton.FloatingActionButton two = (com.getbase.floatingactionbutton.FloatingActionButton) findViewById(R.id.two); View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(MainActivity.this, "clicked", Toast.LENGTH_SHORT).show(); } }; one.setOnClickListener(onClickListener); two.setOnClickListener(onClickListener); }
@Override public View onCreateView( LayoutInflater inflater, final ViewGroup container, Bundle savedInstance) { View v = inflater.inflate(R.layout.fragment_movement, container, false); croutonParent = container; fabButton = (FloatingActionButton) getActivity().findViewById(R.id.fabButton); fabButton.hide(); /*if(Utils.getDefaultWalletIdPref(getActivity())==-1) fabButton.hide(true); else fabButton.show(true);*/ cursorCardAdapter = new MovementCursorCardAdapter( getActivity(), dbHelper.getMovementsOfWallet( Utils.getDefaultWalletIdPref(getActivity()), Const.KEY_MOVEMENT_DATE, true), false); // dbHelper.getMovementsOfWallet(Utils.getDefaultWalletIdPref(getActivity()), // Const.KEY_MOVEMENT_NAME),false, true); listViewMovement = (CardListView) v.findViewById(R.id.listViewMovement); if (listViewMovement != null) { listViewMovement.setAdapter(cursorCardAdapter); } LayoutAnimationController lac = new LayoutAnimationController( AnimationUtils.loadAnimation(getActivity(), R.anim.table_row_appear), 0.5f); // 0.5f == time between appearance of listview items. listViewMovement.setLayoutAnimation(lac); listViewMovement.setFastScrollEnabled(true); listViewMovement.setEmptyView(v.findViewById(R.id.emtyView)); /*fabButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialogAddMovement(); } }); fabButton.attachToListView(listViewMovement);*/ multiple_actions = (FloatingActionsMenu) v.findViewById(R.id.multiple_actions); fbNewExit = (com.getbase.floatingactionbutton.FloatingActionButton) v.findViewById(R.id.fbNewExit); fbNewEntry = (com.getbase.floatingactionbutton.FloatingActionButton) v.findViewById(R.id.fbNewEntry); fbNewEntry.setOnClickListener(this); fbNewExit.setOnClickListener(this); if (Utils.getDefaultWalletIdPref(getActivity()) == -1) multiple_actions.setVisibility(View.GONE); else fabButton.setVisibility(View.VISIBLE); return v; }
@Override public boolean onDependentViewChanged( CoordinatorLayout parent, FloatingActionButton child, View dependency) { float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight()); child.setTranslationY(translationY); return true; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test); // 属于其中之一 FloatingActionButton actionC = new FloatingActionButton(getBaseContext()); actionC.setTitle("Hide/Show Action above"); actionC.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // actionB.setVisibility(actionB.getVisibility() == View.GONE ? View.VISIBLE : // View.GONE); } }); // 属于其中之一 FloatingActionButton actionA = new FloatingActionButton(getBaseContext()); actionC.setTitle("Hide/Show Action above"); actionC.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // actionB.setVisibility(actionB.getVisibility() == View.GONE ? View.VISIBLE : // View.GONE); } }); // 属于其中之一 FloatingActionButton actionB = new FloatingActionButton(getBaseContext()); actionC.setTitle("Hide/Show Action above"); actionC.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // actionB.setVisibility(actionB.getVisibility() == View.GONE ? View.VISIBLE : // View.GONE); } }); ((FloatingActionsMenu) findViewById(R.id.multiple_actions)).addButton(actionC); ((FloatingActionsMenu) findViewById(R.id.multiple_actions)).addButton(actionB); ((FloatingActionsMenu) findViewById(R.id.multiple_actions)).addButton(actionA); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAccountsLabel = (TextView) findViewById(R.id.api_accounts_label); mAppNameView = (TextView) findViewById(R.id.api_app_settings_app_name); mAppIconView = (ImageView) findViewById(R.id.api_app_settings_app_icon); mPackageName = (TextView) findViewById(R.id.api_app_settings_package_name); mPackageSignature = (TextView) findViewById(R.id.api_app_settings_package_certificate); mStartFab = (FloatingActionButton) findViewById(R.id.fab); mStartFab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { startApp(); } }); setFullScreenDialogClose( new View.OnClickListener() { @Override public void onClick(View v) { cancel(); } }); setTitle(null); Intent intent = getIntent(); mAppUri = intent.getData(); if (mAppUri == null) { Log.e(Constants.TAG, "Intent data missing. Should be Uri of app!"); finish(); return; } else { Log.d(Constants.TAG, "uri: " + mAppUri); loadData(savedInstanceState, mAppUri); } }
@Override public void init(Bundle savedInstanceState) { super.init(savedInstanceState); setToolbar(R.mipmap.ic_arrow_back, "邮件详细"); if (signal != null) { if (signal.objectValue != null) { email = (Email) signal.objectValue; bindData(); } else { if (signal.intValue != 0) { showWaitDialog("正在加载...", true); getEmailById(signal.intValue2 == 4 ? "wail" : ""); } } } // 判断草稿箱和发件箱按钮 if (signal != null && signal.action != null) { flag = signal.intValue2; } switch (flag) { case 2: // 草稿箱 TT_reply.setTitle("编辑"); TT_zhuan.setTitle("发送"); real_delete = ""; delete = "4"; break; case 1: // 发件箱 TT_reply.setTitle("编辑"); real_delete = ""; delete = "4"; break; case 3: // 已删除 real_delete = "1"; delete = ""; break; case 0: // 收件箱 real_delete = ""; delete = "4"; break; } TT_reply.setOnClickListener(this); TT_zhuan.setOnClickListener(this); TT_delete.setOnClickListener(this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // view toolbar = (Toolbar) findViewById(R.id.app_bar); setSupportActionBar(toolbar); // view grid = (GridView) findViewById(R.id.all_room_container); // Menu---------------------------- TextView addThing = (TextView) findViewById(R.id.add_room); addThing.setText("Add device "); items.add(new GridItem("Light", R.mipmap.r_light, R.mipmap.light, GridItem.ItemType.Light)); // Instance of ImageAdapter Class grid.setAdapter(new GridItemAdapter(this, items, this)); FloatingActionButton b0 = new FloatingActionButton(this); final List<FloatingActionButton> button = Arrays.asList(b0); ScrollView menu_container = (ScrollView) findViewById(R.id.fab_menu_container); // FAB_menu----- FloatingActionsMenu fab = new FloatingActionsMenu(this); menu_container.addView(fab); // -----FAB_menu [end] for (final FloatingActionButton b : button) { final GridItem current = items.get(button.indexOf(b)); // b.setTitle(String.valueOf(current.name)); b.setIcon(current.resIconId); b.setColorNormal(Color.parseColor("#FFFFFF")); b.setTag(current.type); fab.addButton(button.get(button.indexOf(b))); b.setOnClickListener( new View.OnClickListener() { @Override public void onClick(final View v) { AlertDialog dialogInputText = new AlertDialog.Builder(DeviceCategoriesActivity.this).create(); // dialogInputText.setTitle("Add " + String.valueOf(current.name)); dialogInputText.setTitle(String.valueOf(current.type)); View dialogView = getLayoutInflater().inflate(R.layout.dialog_input_text_device, null); final EditText dialogTextName = (EditText) dialogView.findViewById(R.id.dialog_text_name); dialogInputText.setView(dialogView); dialogInputText.setButton( "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // grid type GridItem.ItemType type = current.type; String name = dialogTextName.getText().toString(); // add gridItem with correct icon GridItem toBeAdded = addRoom(name, type); // badge Type ++ ((GridItemAdapter) grid.getAdapter()).items.get(button.indexOf(b)).badge++; ((GridItemAdapter) grid.getAdapter()).notifyDataSetChanged(); // item Type add ((WirelessHomeApplication) getApplication()) .roomRepository.addRoom(toBeAdded); Toast.makeText( DeviceCategoriesActivity.this, grid.getChildAt(button.indexOf(b)).getTag() + " successfully created", Toast.LENGTH_LONG) .show(); } }); dialogInputText.show(); } }); } // ----------------------------Menu [end] }
private void loadFloatingMenu() { final FloatingActionsMenu floatMenu = (FloatingActionsMenu) mRootView.findViewById(R.id.float_menu); FloatingActionButton addProfiles = (FloatingActionButton) mRootView.findViewById(R.id.add_button); FloatingActionButton toggleSystem = (FloatingActionButton) mRootView.findViewById(R.id.toggle_system); FloatingActionButton resetButton = (FloatingActionButton) mRootView.findViewById(R.id.reset_button); addProfiles.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // Check if there are actual changes; if (!(AeroActivity.genHelper.doesExist( FilePath.sharedPrefsPath + "com.aero.control_preferences.xml"))) { Toast.makeText(mContext, R.string.pref_profile_no_changes, Toast.LENGTH_LONG).show(); return; } showDialog(new EditText(mContext)); floatMenu.toggle(); } }); toggleSystem.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { String systemStatus = mPerAppPrefs.getString("systemStatus", "false"); if (systemStatus.equals("false")) { systemStatus = "true"; Toast.makeText( mContext, getText(R.string.pref_profile_showSystem) + ": " + getText(R.string.enabled), Toast.LENGTH_SHORT) .show(); } else { systemStatus = "false"; Toast.makeText( mContext, getText(R.string.pref_profile_showSystem) + ": " + getText(R.string.disabled), Toast.LENGTH_SHORT) .show(); } mPerAppPrefs.edit().putString("systemStatus", systemStatus).commit(); mPerAppDialogVisible = false; floatMenu.toggle(); } }); resetButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { showResetDialog(); floatMenu.toggle(); } }); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); artEvent1Text = (TextView) view.findViewById(R.id.artEvent1Text); artEvent2Text = (TextView) view.findViewById(R.id.artEvent2Text); artEvent3Text = (TextView) view.findViewById(R.id.artEvent3Text); artEvent4Text = (TextView) view.findViewById(R.id.artEvent4Text); subhi = (TextView) view.findViewById(R.id.shubi); sanjana = (TextView) view.findViewById(R.id.sanjana); Typeface tfMatter = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Reckoner.ttf"); Typeface Oswald = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Oswald-Regular.ttf"); subhi.setTypeface(Oswald, Typeface.NORMAL); sanjana.setTypeface(Oswald, Typeface.NORMAL); subhiCallfab = (FloatingActionButton) view.findViewById(R.id.shubiCallFab); sanjanaCallfab = (FloatingActionButton) view.findViewById(R.id.sanjanaCallFab); subhiCallfab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse("tel:09912758669")); startActivity(callIntent); } }); sanjanaCallfab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse("tel:0818592061")); startActivity(callIntent); } }); artEvent1Text.setTypeface(tfMatter, Typeface.NORMAL); artEvent2Text.setTypeface(tfMatter, Typeface.NORMAL); artEvent3Text.setTypeface(tfMatter, Typeface.NORMAL); artEvent4Text.setTypeface(tfMatter, Typeface.NORMAL); artEvent1Ripple = (MaterialRippleLayout) view.findViewById(R.id.artEvent1Ripple); artEvent2Ripple = (MaterialRippleLayout) view.findViewById(R.id.artEvent2Ripple); artEvent3Ripple = (MaterialRippleLayout) view.findViewById(R.id.artEvent3Ripple); artEvent4Ripple = (MaterialRippleLayout) view.findViewById(R.id.artEvent4Ripple); artEvent1Ripple.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { new MaterialDialog.Builder(getActivity()) .title( Html.fromHtml( "Avant Grade" + "<br />" + "<small>" + "15 MAR 1:00 pm" + "</small>" + "<br />" + "<small>" + "Rocks" + "</small>")) .content(R.string.avant_grade) .positiveText("CLOSE") .positiveColorRes(R.color.material_red_400) .titleGravity(GravityEnum.CENTER) .titleColorRes(R.color.material_red_400) .contentColorRes(android.R.color.white) .backgroundColorRes(R.color.material_blue_grey_800) .dividerColorRes(R.color.material_pink_500) .btnSelector(R.drawable.md_btn_selector_custom, DialogAction.POSITIVE) .positiveColor(Color.WHITE) .theme(Theme.DARK) .show(); } }); artEvent2Ripple.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { new MaterialDialog.Builder(getActivity()) .title( Html.fromHtml( "Schedios" + "<br />" + "<small>" + "14 MAR 2:00 pm" + "</small>" + "<br />" + "<small>" + "F 201" + "</small>")) .content(R.string.schedios) .positiveText("CLOSE") .positiveColorRes(R.color.material_red_400) .titleGravity(GravityEnum.CENTER) .titleColorRes(R.color.material_red_400) .contentColorRes(android.R.color.white) .backgroundColorRes(R.color.material_blue_grey_800) .dividerColorRes(R.color.material_pink_500) .btnSelector(R.drawable.md_btn_selector_custom, DialogAction.POSITIVE) .positiveColor(Color.WHITE) .theme(Theme.DARK) .show(); } }); artEvent3Ripple.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { new MaterialDialog.Builder(getActivity()) .title( Html.fromHtml( "Spawn It" + "<br />" + "<small>" + "13 MAR 11:00 am" + "</small>" + "<br />" + "<small>" + "F 201" + "</small>")) .content(R.string.spawn_it) .positiveText("CLOSE") .positiveColorRes(R.color.material_red_400) .titleGravity(GravityEnum.CENTER) .titleColorRes(R.color.material_red_400) .contentColorRes(android.R.color.white) .backgroundColorRes(R.color.material_blue_grey_800) .dividerColorRes(R.color.material_pink_500) .btnSelector(R.drawable.md_btn_selector_custom, DialogAction.POSITIVE) .positiveColor(Color.WHITE) .theme(Theme.DARK) .show(); } }); artEvent4Ripple.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { new MaterialDialog.Builder(getActivity()) .title( Html.fromHtml( "Waste smART" + "<br />" + "<small>" + "15 MAR 3:00 pm" + "</small>" + "<br />" + "<small>" + "Stage 2" + "</small>")) .content(R.string.waste_smart) .positiveText("CLOSE") .positiveColorRes(R.color.material_red_400) .titleGravity(GravityEnum.CENTER) .titleColorRes(R.color.material_red_400) .contentColorRes(android.R.color.white) .backgroundColorRes(R.color.material_blue_grey_800) .dividerColorRes(R.color.material_pink_500) .btnSelector(R.drawable.md_btn_selector_custom, DialogAction.POSITIVE) .positiveColor(Color.WHITE) .theme(Theme.DARK) .show(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_question); MobclickAgent.onEvent(this, Mob.Event_Open_Question); loadingView = (LoadingView) findViewById(R.id.question_progress_loading); loadingView.setReloadListener(this); progressBar = (ProgressBar) findViewById(R.id.question_loading); Toolbar toolbar = (Toolbar) findViewById(R.id.action_bar); setSupportActionBar(toolbar); toolbar.setOnClickListener( new View.OnClickListener() { boolean preparingToScrollToHead = false; @Override public void onClick(View v) { if (preparingToScrollToHead) { listView.setSelection(0); } else { preparingToScrollToHead = true; new Handler() .postDelayed( new Runnable() { @Override public void run() { preparingToScrollToHead = false; } }, 200); } } }); View headView = findViewById(R.id.head_view); question = (Question) getIntent().getSerializableExtra(Consts.Extra_Question); notice_id = getIntent().getStringExtra(Consts.Extra_Notice_Id); listView = (LListView) findViewById(R.id.list_detail); adapter = new QuestionDetailAdapter(this); listView.setAdapter(adapter); listView.setCanPullToLoadMore(false); listView.setOnRefreshListener(this); listView.setOnItemClickListener(onItemClickListener); floatingActionsMenu = (FloatingActionsMenu) findViewById(R.id.layout_operation); FloatingActionButton replyButton = (FloatingActionButton) findViewById(R.id.button_reply); FloatingActionButton recomButton = (FloatingActionButton) findViewById(R.id.button_recommend); FloatingActionButton favorButton = (FloatingActionButton) findViewById(R.id.button_favor); replyButton.setOnClickListener(this); recomButton.setOnClickListener(this); favorButton.setOnClickListener(this); AutoHideUtil.applyListViewAutoHide( this, listView, headView, floatingActionsMenu, (int) getResources().getDimension(R.dimen.abc_action_bar_default_height_material)); floatingActionsMenu.setVisibility(View.GONE); loadData(-1); }