Java Code Examples for android.view.View#OnClickListener
The following examples show how to use
android.view.View#OnClickListener .
These examples are extracted from open source projects.
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 Project: Android-Plugin-Framework File: RootActivity.java License: MIT License | 6 votes |
private View.OnClickListener getMenuItemCLick(final int menuIndex, final int color) { return new View.OnClickListener() { @Override public void onClick(View v) { if (menuIndex == curretMenuIndex) { onBackPressed(); } else if (menuIndex == 0 && !(currentFragment instanceof WaterFragment)) { ((MenuAnimation) currentFragment).exitFromMenu(); WaterFragment waterFragment = new WaterFragment(); waterFragment.setIntroAnimate(true); goToFragment(waterFragment); hideMenu(); selectMenuItem(menuIndex, color); } else if (menuIndex == 1 && !(currentFragment instanceof WindFragment)) { ((MenuAnimation) currentFragment).exitFromMenu(); WindFragment windFragment = new WindFragment(); windFragment.setIntroAnimate(true); goToFragment(windFragment); hideMenu(); selectMenuItem(menuIndex, color); } else if (menuIndex == 2) { startActivity(new Intent(RootActivity.this, PlayGroundActivity.class)); onBackPressed(); } } }; }
Example 2
Source Project: Easy_xkcd File: PrefHelper.java License: Apache License 2.0 | 6 votes |
public void showFeatureSnackbar(final Activity activity, FloatingActionButton fab) { if (!sharedPrefs.getBoolean(CUSTOM_THEMES_SNACKBAR, false)) { View.OnClickListener oc = new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(activity, NestedSettingsActivity.class); intent.putExtra("key", "appearance"); activity.startActivityForResult(intent, 1); } }; SharedPreferences.Editor editor = sharedPrefs.edit(); editor.putBoolean(CUSTOM_THEMES_SNACKBAR, true); editor.apply(); Snackbar.make(fab, R.string.snackbar_feature, Snackbar.LENGTH_LONG) .setAction(R.string.snackbar_feature_oc, oc) .show(); } }
Example 3
Source Project: TodoFluxArchitecture File: BaseActivity.java License: Apache License 2.0 | 5 votes |
/** * 设置toolbar最右侧按钮的图片,以及点击事件. * * @param toolbar toolbar * @param resId 图片的resId * @param onClickListener 点击事件监听 */ protected void setActionImageView(Toolbar toolbar, @DrawableRes int resId, View.OnClickListener onClickListener) { View actionView = ButterKnife.findById(toolbar, R.id.actionView); ImageView actionImageView = ButterKnife.findById(toolbar, R.id.actionImageView); if (actionImageView != null) { actionView.setVisibility(View.VISIBLE); actionImageView.setImageResource(resId); actionView.setOnClickListener(onClickListener); } }
Example 4
Source Project: demo-firebase-android File: BaseActivityDi.java License: The Unlicense | 5 votes |
protected final void showHamburger(boolean show, @Nullable View.OnClickListener listener) { if (show) { ibToolbarHamburger.setVisibility(View.VISIBLE); ibToolbarHamburger.setOnClickListener(listener); } else { ibToolbarHamburger.setVisibility(View.INVISIBLE); } }
Example 5
Source Project: PictureSelector File: SelectorFragment.java License: Apache License 2.0 | 5 votes |
private View.OnClickListener getChangeFolderListener() { return new View.OnClickListener() { @Override public void onClick(View v) { if (mFolderDialog == null) { mFolderDialog = new FolderDialog(getActivity(), mData); mFolderDialog.setOnFolderSelectedListener(SelectorFragment.this); } mFolderDialog.show(); } }; }
Example 6
Source Project: diycode File: ViewHolder.java License: Apache License 2.0 | 5 votes |
/** * 设置监听器 * * @param l 监听器 * @param ids view 的 id */ public void setOnClickListener(View.OnClickListener l, int... ids) { if (ids == null) { return; } for (int id : ids) { get(id).setOnClickListener(l); } }
Example 7
Source Project: COCOFramework File: AdapterViewFragment.java License: Apache License 2.0 | 5 votes |
protected View getEmptyView(final int layout, final int msg, final int button, final View.OnClickListener listener) { final View view = LayoutInflater.from(context).inflate(layout, null); final CocoQuery nq = new CocoQuery(view); nq.id(R.id.empty_msg).text(msg); nq.id(R.id.empty_button).text(button).clicked(listener); return view; }
Example 8
Source Project: BaseRecyclerViewAdapterHelper File: HeaderAndFooterUseActivity.java License: MIT License | 5 votes |
private View getFooterView(int type, View.OnClickListener listener) { View view = getLayoutInflater().inflate(R.layout.footer_view, mRecyclerView, false); if (type == 1) { ImageView imageView = view.findViewById(R.id.iv); imageView.setImageResource(R.mipmap.rm_icon); } view.setOnClickListener(listener); return view; }
Example 9
Source Project: Stringlate File: ActivityUtils.java License: MIT License | 4 votes |
public void showSnackBar(@StringRes int stringResId, boolean showLong, @StringRes int actionResId, View.OnClickListener listener) { Snackbar.make(_activity.findViewById(android.R.id.content), stringResId, showLong ? Snackbar.LENGTH_LONG : Snackbar.LENGTH_SHORT) .setAction(actionResId, listener) .show(); }
Example 10
Source Project: DropDownMenu File: ItemViewHolder.java License: Apache License 2.0 | 4 votes |
public ItemViewHolder(Context mContext, ViewGroup parent, View.OnClickListener mListener) { super(UIUtil.infalte(mContext, R.layout.holder_item, parent)); textView = ButterKnife.findById(itemView, R.id.tv_item); this.mListener = mListener; }
Example 11
Source Project: epoxy File: TestFieldPropChildViewModel_.java License: Apache License 2.0 | 4 votes |
@Nullable public View.OnClickListener value() { return value_OnClickListener; }
Example 12
Source Project: EasyAbout File: AboutItem.java License: MIT License | 4 votes |
public View.OnClickListener getOnClickListener() { return onClickListener; }
Example 13
Source Project: spanner File: SampleJavaActivity.java License: Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sample); TextView textView = findViewById(R.id.text); textView.setMovementMethod(new LinkMovementMethod()); View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(view.getContext(), "Clicked", Toast.LENGTH_LONG).show(); } }; Drawable drawable = getResources().getDrawable(R.drawable.ic_android_16dp); drawable.setBounds(0, 0, drawable.getIntrinsicWidth() * 2, drawable.getIntrinsicHeight() * 2); // @formatter:off Spannable spannable = new Spanner() .append("Original text\n\n") .append("Big and blurry\n", Spans.sizePX(100)) .span("blurry", blur(5.0f, BlurMaskFilter.Blur.SOLID)) .append("big in DP\n", sizeDP(30)) .append("50% of original size\n", scaleSize(0.5f)) .append("bold\n", bold()) .append("italic\n", italic()) .append("bold and italic\n", boldItalic()) .append("custom typeface\n", font("sans-serif-black")) .append("strike through\n", strikeThrough()) .append("underline\n", underline()) .append("background\n", background(Color.YELLOW)) .append("foreground\n", foreground(Color.RED)) .append("subscript\n", subscript()) .append("superscript\n", superscript()) .append("Image with custom bounds: ").append(image(drawable)).append("\n") .append("Image from resources: ").append(image(this, R.drawable.ic_android_16dp)).append("\n") .append("quite\n", quote()) .append("The quick brown fox jumps over the lazy dog\n", bold(), foreground(0xFF904f1c), Spans.quote()) .span("fox", foreground(Color.RED)) .span("dog", foreground(Color.RED)) .append("First occurrence, Second occurrence\n") .span(292,"occurrence",background(Color.GREEN)) .append("Custom\n", custom(new CustomSpan())) .append("Click here\n", click(onClickListener)) .append("http://www.android.com\n", url("http://www.android.com")) ; // @formatter:on textView.setText(spannable); }
Example 14
Source Project: green_android File: UI.java License: GNU General Public License v3.0 | 4 votes |
public static < T extends View > T mapClick(final Activity activity, final int id, final View.OnClickListener fn) { final T v = find(activity, id); if (v != null) v.setOnClickListener(fn); return v; }
Example 15
Source Project: navigation-widgets File: NavigationDefaults.java License: MIT License | 4 votes |
public NavigationDefaults navigationIconListener(View.OnClickListener listener) { this.navigationIconListener = listener == null ? DUMMY_NAV_ICON_LISTENER : listener; return this; }
Example 16
Source Project: TutoShowcase File: TutoShowcase.java License: Apache License 2.0 | 4 votes |
public TutoShowcase onClickContentView(@IdRes int viewId, View.OnClickListener onClickListener) { return tutoShowcase.onClickContentView(viewId, onClickListener); }
Example 17
Source Project: MaterialDesignLibrary File: Dialog.java License: Apache License 2.0 | 4 votes |
public void setOnAcceptButtonClickListener( View.OnClickListener onAcceptButtonClickListener) { this.onAcceptButtonClickListener = onAcceptButtonClickListener; if(buttonAccept != null) buttonAccept.setOnClickListener(onAcceptButtonClickListener); }
Example 18
Source Project: dhis2-android-capture-app File: PeriodDialog.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
public PeriodDialog setNegativeListener(View.OnClickListener listener) { this.negativeListener = listener; return this; }
Example 19
Source Project: NGA-CLIENT-VER-OPEN-SOURCE File: ArticleListAdapter.java License: GNU General Public License v2.0 | 4 votes |
public void setMenuTogglerListener(View.OnClickListener menuTogglerListener) { mMenuTogglerListener = menuTogglerListener; }
Example 20
Source Project: KUtils-master File: DialogUIUtils.java License: Apache License 2.0 | 2 votes |
/** * 展示一个仅有一个按钮的对话框 仿iOS中间弹出 * * @param activity 必须为activity * @param msg 提示的内容 * @param bt_msg 按钮的文字 * @param onClickListener 点击事件监听 */ public static void showOnlyOneButtonAlertDialog(Activity activity, String msg, String bt_msg, View.OnClickListener onClickListener) { new AlertDialog(activity).builder().setMsg(msg) .setNegativeButton(bt_msg, onClickListener).show(); }