Java Code Examples for android.view.View#OnClickListener

The following examples show how to use android.view.View#OnClickListener . 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: PrefHelper.java    From Easy_xkcd with Apache License 2.0 6 votes vote down vote up
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 2
Source File: RootActivity.java    From Android-Plugin-Framework with MIT License 6 votes vote down vote up
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 3
Source File: HeaderAndFooterUseActivity.java    From BaseRecyclerViewAdapterHelper with MIT License 5 votes vote down vote up
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 4
Source File: BaseActivity.java    From TodoFluxArchitecture with Apache License 2.0 5 votes vote down vote up
/**
 * 设置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 5
Source File: BaseActivityDi.java    From demo-firebase-android with The Unlicense 5 votes vote down vote up
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 6
Source File: AdapterViewFragment.java    From COCOFramework with Apache License 2.0 5 votes vote down vote up
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 7
Source File: SelectorFragment.java    From PictureSelector with Apache License 2.0 5 votes vote down vote up
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 8
Source File: ViewHolder.java    From diycode with Apache License 2.0 5 votes vote down vote up
/**
 * 设置监听器
 *
 * @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 9
Source File: NavigationDefaults.java    From navigation-widgets with MIT License 4 votes vote down vote up
public NavigationDefaults navigationIconListener(View.OnClickListener listener) {
    this.navigationIconListener = listener == null ? DUMMY_NAV_ICON_LISTENER : listener;
    return this;
}
 
Example 10
Source File: ArticleListAdapter.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 4 votes vote down vote up
public void setMenuTogglerListener(View.OnClickListener menuTogglerListener) {
    mMenuTogglerListener = menuTogglerListener;
}
 
Example 11
Source File: PeriodDialog.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public PeriodDialog setNegativeListener(View.OnClickListener listener) {
    this.negativeListener = listener;
    return this;
}
 
Example 12
Source File: Dialog.java    From MaterialDesignLibrary with Apache License 2.0 4 votes vote down vote up
public void setOnAcceptButtonClickListener(
		View.OnClickListener onAcceptButtonClickListener) {
	this.onAcceptButtonClickListener = onAcceptButtonClickListener;
	if(buttonAccept != null)
		buttonAccept.setOnClickListener(onAcceptButtonClickListener);
}
 
Example 13
Source File: TutoShowcase.java    From TutoShowcase with Apache License 2.0 4 votes vote down vote up
public TutoShowcase onClickContentView(@IdRes int viewId, View.OnClickListener onClickListener) {
    return tutoShowcase.onClickContentView(viewId, onClickListener);
}
 
Example 14
Source File: UI.java    From green_android with GNU General Public License v3.0 4 votes vote down vote up
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 File: SampleJavaActivity.java    From spanner with Apache License 2.0 4 votes vote down vote up
@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 16
Source File: AboutItem.java    From EasyAbout with MIT License 4 votes vote down vote up
public View.OnClickListener getOnClickListener() {
    return onClickListener;
}
 
Example 17
Source File: TestFieldPropChildViewModel_.java    From epoxy with Apache License 2.0 4 votes vote down vote up
@Nullable
public View.OnClickListener value() {
  return value_OnClickListener;
}
 
Example 18
Source File: ItemViewHolder.java    From DropDownMenu with Apache License 2.0 4 votes vote down vote up
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 19
Source File: ActivityUtils.java    From Stringlate with MIT License 4 votes vote down vote up
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 20
Source File: DialogUIUtils.java    From KUtils-master with Apache License 2.0 2 votes vote down vote up
/**
 * 展示一个仅有一个按钮的对话框  仿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();
}