private void setupViews() { drawer = (DrawerLayout) findViewById(R.id.drawerlayout); navview = (NavigationView) findViewById(R.id.navview); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.main_drawer_open, R.string.main_drawer_close); //drawer.addDrawerListener(this); toggle.syncState(); navview.setNavigationItemSelectedListener(this); View _view = findViewById(R.id.bottom_search_results); resultsBottom = BottomSheetBehavior.from(_view); resultsBottom.setHideable(true); resultsBottom.setState(BottomSheetBehavior.STATE_HIDDEN); resultsRv = (RecyclerView) findViewById(R.id.rv_results); resultsRv.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.VERTICAL, false)); photoIv = (SquareImageView) findViewById(R.id.iv_photo); searchFab = (FloatingActionButton) findViewById(R.id.fab_search); closeBottomBtn = (AppCompatImageButton) findViewById(R.id.btn_close_bottom); indicatorLoadingLayout = (LinearLayout) findViewById(R.id.layout_main_loading); indicatorStatusTv = (AppCompatTextView) findViewById(R.id.tv_progress_status); AppCompatTextView versionAppTv = navview.getHeaderView(0).findViewById(R.id.tv_header_app_version); versionAppTv.setText(C.getAppVersion(MainActivity.this)); }
private void initPopupMenu() { @SuppressLint("InflateParams") View view = LayoutInflater.from(this).inflate(R.layout.popup_menu, null); mPopupMenu = new PopupWindow(this); mPopupMenu.setBackgroundDrawable(new BitmapDrawable()); mPopupMenu.setContentView(view); mPopupMenu.setOutsideTouchable(true); mPopupMenu.setFocusable(true); mLlControlButtons = (RelativeLayout) view.findViewById(R.id.popup_menu_rl_arrows); mBtnBack = (AppCompatImageButton) view.findViewById(R.id.popup_menu_btn_back); mBtnFoward = (AppCompatImageButton) view.findViewById(R.id.popup_menu_btn_forward); mBtnBack.setOnClickListener(this); mBtnFoward.setOnClickListener(this); view.findViewById(R.id.popup_menu_btn_refresh).setOnClickListener(this); view.findViewById(R.id.popup_menu_btn_copy_link).setOnClickListener(this); view.findViewById(R.id.popup_menu_btn_open_with_other_browser).setOnClickListener(this); view.findViewById(R.id.popup_menu_btn_share).setOnClickListener(this); }
private void initPopupMenu() { @SuppressLint("InflateParams") View view = LayoutInflater.from(this).inflate(R.layout.popup_menu, null); mPopupMenu = new PopupWindow(this); mPopupMenu.setContentView(view); mPopupMenu.setOutsideTouchable(true); mPopupMenu.setBackgroundDrawable(new ColorDrawable(0)); mPopupMenu.setFocusable(true); mLlControlButtons = (RelativeLayout) view.findViewById(R.id.popup_menu_rl_arrows); mBtnBack = (AppCompatImageButton) view.findViewById(R.id.popup_menu_btn_back); mBtnFoward = (AppCompatImageButton) view.findViewById(R.id.popup_menu_btn_forward); mBtnBack.setOnClickListener(this); mBtnFoward.setOnClickListener(this); view.findViewById(R.id.popup_menu_btn_refresh).setOnClickListener(this); view.findViewById(R.id.popup_menu_btn_copy_link).setOnClickListener(this); view.findViewById(R.id.popup_menu_btn_open_with_other_browser).setOnClickListener(this); view.findViewById(R.id.popup_menu_btn_share).setOnClickListener(this); }
public UserMessageViewHolder(View itemView) { super(itemView); mTxFirstMessageBody = (DetectLTextView) itemView.findViewById(R.id.tx_first_message_body); mTxSecondMessageBody = (DetectLTextView) itemView.findViewById(R.id.tx_second_message_body); mTxMatchedStatus = (AppCompatTextView) itemView.findViewById(R.id.tx_matched_status); mBtnDeleteMessage = (AppCompatImageButton) itemView.findViewById(R.id.btn_delete); mTxMessageStatus = (AppCompatTextView) itemView.findViewById(R.id.tx_message_status); mTxCrossIn = (AppCompatTextView) itemView.findViewById(R.id.tx_cross_in); mVSeparator = itemView.findViewById(R.id.v_separator); //handle delete action mBtnDeleteMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mUserMessageListener != null) { mUserMessageListener.onDeleteMessage(mData.get(getAdapterPosition()).getMessageId(), getAdapterPosition()); } } }); }
@Override public void initViews() { inflater.inflate(R.layout.widget_metric_stopwatch, this); startResumeButton = (AppCompatImageButton) findViewById(R.id.start_resume); findViewById(R.id.reset).setOnClickListener(v -> reset()); findViewById(R.id.reset).setVisibility(View.GONE); startResumeButton.setOnClickListener(v -> { if (!running) { startResumeButton.setImageResource(R.drawable.ic_pause_black_48dp); start(); } else { startResumeButton.setImageResource(R.drawable.ic_play_arrow_black_48dp); stop(); } }); }
private View createButton() { ImageButton button = new AppCompatImageButton(context); view.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); button.setImageResource(new Attrs(context).resourceId(R.attr.timeIcon)); // button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { saveNode(); TimePickerFragment newFragment = new TimePickerFragment(); newFragment.setComponent(TimeAttributeComponent.this); newFragment.show(context.getSupportFragmentManager(), "timePicker"); } }); return button; }
/** * A matcher to get the ActionBar home/hamburger button. * <p> * Taken from: http://stackoverflow.com/a/34658817/4624156 * * @return Matcher. */ public static Matcher<View> getHamburgerButton() { return allOf( withParent(withClassName(is(Toolbar.class.getName()))), withClassName(anyOf(is(ImageButton.class.getName()), is(AppCompatImageButton.class.getName())))); }
/** * Note that to use this method rather than {@link Toolbar#setNavigationIcon(int)}, as this method will expand the click area. * * @param icon the navigation icon. */ public void setNavIcon(@DrawableRes int icon) { setNavigationIcon(icon); AppCompatImageButton navIcon = (AppCompatImageButton) getChildAt(1); Toolbar.LayoutParams lp = (LayoutParams) navIcon.getLayoutParams(); lp.width = ViewGroup.LayoutParams.WRAP_CONTENT; lp.height = ViewGroup.LayoutParams.MATCH_PARENT; navIcon.setScaleType(ImageView.ScaleType.CENTER_INSIDE); navIcon.setLayoutParams(lp); }
public PicDialog(Context context) { super(context, R.style.AppNoActionBarTheme); setOwnerActivity((Activity) context); setContentView(R.layout.dialog_pic); StatusBarUtil.MIUISetStatusBarLightMode(getOwnerActivity(), true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { View decorView = getWindow().getDecorView(); int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; decorView.setSystemUiVisibility(option); getWindow().setStatusBarColor(Color.TRANSPARENT); } ButterKnife.bind(this); if ((boolean) SPUtils.get(getContext(), AppConfig.click_to_back, false)) photoDraweeView.setOnViewTapListener(new OnViewTapListener() { @Override public void onViewTap(View view, float x, float y) { dismiss(); } }); photoDraweeView.setAllowParentInterceptOnEdge(false); photoDraweeView.setEnableDraweeMatrix(false); for (AppCompatImageButton imageButton : imageButtons) imageButton.setOnClickListener(this); getWindow().setWindowAnimations(R.style.dialogStyle); behavior = BottomSheetBehavior.from(findViewById(R.id.bottom_view)); }
ViewHolder(View itemView) { super(itemView); cardView = (CardView) itemView.findViewById(R.id.cardView); skeletonGroup = (SkeletonGroup) itemView.findViewById(R.id.skeletonGroup); photoACImgV = (AppCompatImageView) itemView.findViewById(R.id.photoACImgV); newFlagTv = (TextView) itemView.findViewById(R.id.newFlagTv); titleTv = (TextView) itemView.findViewById(R.id.titleTv); descriptionTv = (TextView) itemView.findViewById(R.id.descriptionTv); addToParkingImgBtn = (AppCompatImageButton) itemView.findViewById(R.id.addToParkingImgBtn); compareImgBtn = (AppCompatImageButton) itemView.findViewById(R.id.compareImgBtn); priceTv = (TextView) itemView.findViewById(R.id.priceTv); }
void initView() { mMapView = (MapView) findViewById(R.id.map); mLocbtn = (AppCompatImageButton) findViewById(R.id.locbtn); mActionLocate = (FloatingActionButton) findViewById(R.id.action_locate); mActionSettings = (FloatingActionButton) findViewById(R.id.action_settings); mActionReminder = (FloatingActionButton) findViewById(R.id.action_reminder); mFloatingActionsMenu = (FloatingActionsMenu) findViewById(R.id.floating_actions_menu); mInfoTextView = (TextView) findViewById(R.id.info_text_view); mActionLocate.setOnClickListener(this); mActionSettings.setOnClickListener(this); mActionReminder.setOnClickListener(this); mLocbtn.setOnClickListener(this); }
public ViewHolder(View itemView) { super(itemView); txtRule = (TextView) itemView.findViewById(R.id.txt_rule); btnDelete = (AppCompatImageButton) itemView.findViewById(R.id.btn_delete); btnDelete.setOnClickListener(this); }
@SuppressLint("SetJavaScriptEnabled") private void bindView() { // Toolbar mTvTitle = (TextView) findViewById(R.id.toolbar_tv_title); mTvUrl = (TextView) findViewById(R.id.toolbar_tv_url); findViewById(R.id.toolbar_root).setBackgroundColor(getIntent().getIntExtra(EXTRA_COLOR, Color.BLACK)); mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.a_web_viewer_coordinatorlayout); mProgressBar = (ProgressBar) findViewById(R.id.a_web_viewer_pb); mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.a_web_viewer_srl); mWebView = (WebView) findViewById(R.id.a_web_viewer_wv); mSwipeRefreshLayout.setOnRefreshListener(this); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { webSettings.setDisplayZoomControls(false); } webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(true); webSettings.setDomStorageEnabled(true); mWebView.setWebChromeClient(new MyWebChromeClient()); mWebView.setWebViewClient(new MyWebViewClient()); mWebView.setDownloadListener(this); mWebView.setOnCreateContextMenuListener(this); mBtnMore = (AppCompatImageButton) findViewById(R.id.toolbar_btn_more); //noinspection ConstantConditions findViewById(R.id.toolbar_btn_close).setOnClickListener(this); //noinspection ConstantConditions mBtnMore.setOnClickListener(this); // PopupWindow initPopupMenu(); }
@SuppressLint("SetJavaScriptEnabled") private void bindView() { // Toolbar mTvTitle = (TextView) findViewById(R.id.toolbar_tv_title); mTvUrl = (TextView) findViewById(R.id.toolbar_tv_url); mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.a_web_viewer_coordinatorlayout); mProgressBar = (ProgressBar) findViewById(R.id.a_web_viewer_pb); mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.a_web_viewer_srl); mWebView = (WebView) findViewById(R.id.a_web_viewer_wv); mSwipeRefreshLayout.setOnRefreshListener(this); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { webSettings.setDisplayZoomControls(false); } webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(true); webSettings.setDomStorageEnabled(true); mWebView.setWebChromeClient(new MyWebChromeClient()); mWebView.setWebViewClient(new MyWebViewClient()); mWebView.setDownloadListener(this); mWebView.setOnCreateContextMenuListener(this); mBtnMore = (AppCompatImageButton) findViewById(R.id.toolbar_btn_more); //noinspection ConstantConditions findViewById(R.id.toolbar_btn_close).setOnClickListener(this); //noinspection ConstantConditions mBtnMore.setOnClickListener(this); // PopupWindow initPopupMenu(); }
protected void findViews() { content = (LinearLayout) findViewById(R.id.content); stepsScrollView = (ScrollView) findViewById(R.id.steps_scroll); progressBar = (ProgressBar) findViewById(R.id.progress_bar); previousStepButton = (AppCompatImageButton) findViewById(R.id.down_previous); nextStepButton = (AppCompatImageButton) findViewById(R.id.down_next); bottomNavigation = (RelativeLayout) findViewById(R.id.bottom_navigation); }
private void setupControlPanel() { controlPanel = (LinearLayoutCompat) findViewById(R.id.control); bulletButton = (StatusImageButton) findViewById(R.id.bullet); quoteButton = (StatusImageButton) findViewById(R.id.quote); attachmentButton = (AppCompatImageButton) findViewById(R.id.attachment); dotsButton = (AppCompatImageButton) findViewById(R.id.dots); playButton = (AppCompatImageButton) findViewById(R.id.play); bulletButton.setOnClickListener(this); quoteButton.setOnClickListener(this); attachmentButton.setOnClickListener(this); dotsButton.setOnClickListener(this); playButton.setOnClickListener(this); bulletButton.setOnLongClickListener(this); quoteButton.setOnLongClickListener(this); attachmentButton.setOnLongClickListener(this); dotsButton.setOnLongClickListener(this); playButton.setOnLongClickListener(this); RxBus.getInstance().toObservable(BlockEvent.class) .subscribe(new Action1<BlockEvent>() { @Override public void call(BlockEvent event) { bulletButton.setActivated(event.isBullet()); quoteButton.setActivated(event.isQuote()); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); AppCompatImageButton imageButton = (AppCompatImageButton) findViewById(R.id.imageButton); try { boolean isEncrypted = getSystemProperty("ro.crypto.state", "").toLowerCase().equals("encrypted"); if (isEncrypted) { /* Positive icon */ imageButton.setImageResource(R.drawable.ic_check_black_24dp); imageButton.setSupportBackgroundTintList(ContextCompat.getColorStateList(this, R.color.green)); imageButton.setOnClickListener(view -> snack(view, "Disk is fully encrypted :)")); } else { imageButton.setOnClickListener(view -> snack(view, "Disk is not encrypted :(")); } } catch (Exception e) { Log.e(TAG, e.getMessage(), e); /* Unknown icon */ imageButton.setImageResource(R.drawable.ic_warning_black_24dp1); // Foreground color imageButton.setColorFilter(ContextCompat.getColor(this, R.color.black)); // Background color imageButton.setSupportBackgroundTintList(ContextCompat.getColorStateList(this, R.color.transparent)); // Listener imageButton.setOnClickListener(view -> snack(view, e.getMessage())); } }
/** * @param previous The Button to navigate one slide back. * @param next The Button to navigate one slide forth. Also used to show the done icon, if the * current Slide is the last Slide. * @param skip The Button to skip the introduction. * @param showPreviousButton If the Button to navigate back should not be shown, pass false. * @param showSkipButton If the Button for skipping should not be shown, pass false. * @param slideAmount The amount of Slides. */ public ButtonManager(@NonNull AppCompatImageButton previous, @NonNull AppCompatImageButton next, @NonNull Button skip, boolean showPreviousButton, boolean showSkipButton, int slideAmount) { this.previous = previous; this.next = next; this.skip = skip; this.showPreviousButton = showPreviousButton; this.showSkipButton = showSkipButton; this.slideAmount = slideAmount; init(); }
@SuppressLint({"PrivateResource", "InlinedApi"}) @Override protected int getDefaultViewDefStyleAttr(View view) { if (view instanceof AppCompatRadioButton) { return R.attr.radioButtonStyle; } else if (view instanceof AppCompatCheckBox) { return R.attr.checkboxStyle; } else if (view instanceof AppCompatButton) { return R.attr.buttonStyle; } else if (view instanceof AppCompatMultiAutoCompleteTextView) { return R.attr.autoCompleteTextViewStyle; } else if (view instanceof AppCompatAutoCompleteTextView) { return R.attr.autoCompleteTextViewStyle; } else if (view instanceof AppCompatEditText) { return R.attr.editTextStyle; } else if (view instanceof AppCompatCheckedTextView) { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 ? android.R.attr.checkedTextViewStyle : 0; } else if (view instanceof AppCompatTextView) { return android.R.attr.textViewStyle; } else if (view instanceof AppCompatSpinner) { return R.attr.spinnerStyle; } else if (view instanceof AppCompatImageButton) { return R.attr.imageButtonStyle; } else if (view instanceof AppCompatRatingBar) { return R.attr.ratingBarStyle; } else if (view instanceof AppCompatSeekBar) { return R.attr.seekBarStyle; } else { return super.getDefaultViewDefStyleAttr(view); } }
private View createButton() { ImageButton button = new AppCompatImageButton(context); view.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); button.setImageResource(new Attrs(context).resourceId(R.attr.goToTodayIcon)); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { saveNode(); DatePickerFragment newFragment = new DatePickerFragment(); newFragment.setComponent(DateAttributeComponent.this); newFragment.show(context.getSupportFragmentManager(), "datePicker"); } }); return button; }
@RequiresApi(21) public void showBrokenScrobblingWarning() { if (controllerCallback == null) controllerCallback = new MediaControllerCallback(null); if (NotificationListenerService.isListeningAuthorized(getActivity())) MediaControllerCallback.registerFallbackControllerCallback(getActivity(), controllerCallback); String[] manufacturers = new String[]{"XIAOMI", "HUAWEI", "HONOR", "LETV"}; final boolean canFix = Arrays.asList(manufacturers).contains(Build.BRAND.toUpperCase()); if (canFix && !PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("nls_warning_removed", false)) { final ViewGroup nlsWarning = (ViewGroup) LayoutInflater.from(getActivity()).inflate(R.layout.nls_warning, (ViewGroup) getView(), false); AppCompatButton button = nlsWarning.findViewById(R.id.fix_it); button.setText(R.string.fix_it); button.setOnClickListener(view -> { if (!WhiteListUtil.openBootSpecialMenu(getActivity())) { MainActivity.startFeedbackActivity(getActivity(), true); } warningShown = false; removePrompt(nlsWarning, false); }); AppCompatImageButton closeButton = nlsWarning.findViewById(R.id.ic_nls_warning_close); closeButton.setOnClickListener(view -> { removePrompt(nlsWarning, true); PreferenceManager.getDefaultSharedPreferences(getActivity()).edit().putBoolean("nls_warning_removed", true).apply(); }); ((ViewGroup) getView()).addView(nlsWarning); warningShown = true; nlsWarning.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (mRefreshLayout.getProgressViewEndOffset() == 0) mRefreshLayout.setProgressViewOffset(true, 0, nlsWarning.getMeasuredHeight()); nlsWarning.getViewTreeObserver().removeGlobalOnLayoutListener(this); } }); } }
private void initView() { // inflate numpad numpadLayout = (GridLayout) inflate(getContext(), R.layout.view_num_pad, null); addView(numpadLayout); // set icon for the delete button final AppCompatImageButton deleteButton = (AppCompatImageButton) numpadLayout.findViewById(R.id.numpad_delete_btn); final IconicsDrawable deleteIcon = IconUtils.icon(getContext(), GoogleMaterial.Icon.gmd_tag_backspace, R.color.white, 20); deleteButton.setImageDrawable(deleteIcon); // add listeners for (int i = 0; i < numpadLayout.getChildCount(); i++) { numpadLayout.getChildAt(i).setOnClickListener(new NumpadButtonListener()); } }
public MyViewHolder(View itemView) { super(itemView); simpleDraweeView = (SimpleDraweeView) itemView.findViewById(R.id.fresco); simpleDraweeView.getHierarchy().setProgressBarImage(new ProgressBarDrawable()); imageButton = (AppCompatImageButton) itemView.findViewById(R.id.love_button); }
public AppCompatImageButton getIconImageButton() { return this.iconImageButton; }
public AppCompatImageButton getEndIconImageButton() { return this.endIconImageButton; }
private void addSearchOnPageItem(Menu menu) { toolbar.inflateMenu(R.menu.theme_search_menu); MenuItem searchOnPageMenuItem = menu.findItem(R.id.action_search); searchOnPageMenuItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS); SearchView searchView = (SearchView) searchOnPageMenuItem.getActionView(); searchView.setTag(searchViewTag); searchView.setOnSearchClickListener(v -> { if (searchView.getTag().equals(searchViewTag)) { ImageView searchClose = (ImageView) searchView.findViewById(android.support.v7.appcompat.R.id.search_close_btn); if (searchClose != null) ((ViewGroup) searchClose.getParent()).removeView(searchClose); ViewGroup.LayoutParams navButtonsParams = new ViewGroup.LayoutParams(App.px48, App.px48); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.actionBarItemBackground, outValue, true); AppCompatImageButton btnNext = new AppCompatImageButton(searchView.getContext()); btnNext.setImageDrawable(App.getVecDrawable(getContext(), R.drawable.ic_toolbar_search_next)); btnNext.setBackgroundResource(outValue.resourceId); AppCompatImageButton btnPrev = new AppCompatImageButton(searchView.getContext()); btnPrev.setImageDrawable(App.getVecDrawable(getContext(), R.drawable.ic_toolbar_search_prev)); btnPrev.setBackgroundResource(outValue.resourceId); ((LinearLayout) searchView.getChildAt(0)).addView(btnPrev, navButtonsParams); ((LinearLayout) searchView.getChildAt(0)).addView(btnNext, navButtonsParams); btnNext.setOnClickListener(v1 -> findNext(true)); btnPrev.setOnClickListener(v1 -> findNext(false)); searchViewTag++; } }); SearchManager searchManager = (SearchManager) getMainActivity().getSystemService(Context.SEARCH_SERVICE); if (null != searchManager) { searchView.setSearchableInfo(searchManager.getSearchableInfo(getMainActivity().getComponentName())); } searchView.setIconifiedByDefault(true); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { findText(newText); return false; } }); }
private void addSearchOnPageItem(Menu menu) { toolbar.inflateMenu(R.menu.theme_search_menu); MenuItem searchOnPageMenuItem = menu.findItem(R.id.action_search); searchOnPageMenuItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS); /*MenuItemCompat.setOnActionExpandListener(searchOnPageMenuItem, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionCollapse(MenuItem item) { toggleMessagePanelItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS); return true; } @Override public boolean onMenuItemActionExpand(MenuItem item) { toggleMessagePanelItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_NEVER); return true; } });*/ SearchView searchView = (SearchView) searchOnPageMenuItem.getActionView(); searchView.setTag(searchViewTag); searchView.setOnSearchClickListener(v -> { if (searchView.getTag().equals(searchViewTag)) { ImageView searchClose = (ImageView) searchView.findViewById(android.support.v7.appcompat.R.id.search_close_btn); if (searchClose != null) ((ViewGroup) searchClose.getParent()).removeView(searchClose); ViewGroup.LayoutParams navButtonsParams = new ViewGroup.LayoutParams(App.px48, App.px48); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.actionBarItemBackground, outValue, true); AppCompatImageButton btnNext = new AppCompatImageButton(searchView.getContext()); btnNext.setImageDrawable(App.getVecDrawable(getContext(), R.drawable.ic_toolbar_search_next)); btnNext.setBackgroundResource(outValue.resourceId); AppCompatImageButton btnPrev = new AppCompatImageButton(searchView.getContext()); btnPrev.setImageDrawable(App.getVecDrawable(getContext(), R.drawable.ic_toolbar_search_prev)); btnPrev.setBackgroundResource(outValue.resourceId); ((LinearLayout) searchView.getChildAt(0)).addView(btnPrev, navButtonsParams); ((LinearLayout) searchView.getChildAt(0)).addView(btnNext, navButtonsParams); btnNext.setOnClickListener(v1 -> findNext(true)); btnPrev.setOnClickListener(v1 -> findNext(false)); searchViewTag++; } }); SearchManager searchManager = (SearchManager) getMainActivity().getSystemService(Context.SEARCH_SERVICE); if (null != searchManager) { searchView.setSearchableInfo(searchManager.getSearchableInfo(getMainActivity().getComponentName())); } searchView.setIconifiedByDefault(true); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { findText(newText); return false; } }); }
private View createSurveyButton() { ImageButton button = new AppCompatImageButton(getActivity()); button.setImageResource(R.drawable.ic_menu_home); return button; }
private void addIconTab(final int position, int resId) { ImageButton tab = new AppCompatImageButton(getContext()); tab.setImageResource(resId); addTab(position, tab); }
/** * Sets the specified image button to the given state, while modifying or * "graying-out" the icon as well * * @param enabled The state of the menu item * @param item The menu item to modify * @param iconResId The icon ID */ static void setImageButtonEnabled(boolean enabled, AppCompatImageButton item, int iconResId, Context context) { item.setEnabled(enabled); Drawable originalIcon = ContextCompat.getDrawable(context, iconResId); Drawable icon = enabled ? originalIcon : convertDrawableToGrayScale(originalIcon); item.setImageDrawable(icon); }