android.view.View#OnClickListener ( )源码实例Demo

下面列出了android.view.View#OnClickListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Android-Plugin-Framework   文件: RootActivity.java
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();
      }
    }
  };
}
 
源代码2 项目: Easy_xkcd   文件: PrefHelper.java
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();
    }
}
 
源代码3 项目: TodoFluxArchitecture   文件: BaseActivity.java
/**
 * 设置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);
    }
}
 
源代码4 项目: demo-firebase-android   文件: BaseActivityDi.java
protected final void showHamburger(boolean show, @Nullable View.OnClickListener listener) {
    if (show) {
        ibToolbarHamburger.setVisibility(View.VISIBLE);
        ibToolbarHamburger.setOnClickListener(listener);
    } else {
        ibToolbarHamburger.setVisibility(View.INVISIBLE);
    }
}
 
源代码5 项目: PictureSelector   文件: SelectorFragment.java
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();
        }
    };
}
 
源代码6 项目: diycode   文件: ViewHolder.java
/**
 * 设置监听器
 *
 * @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);
    }
}
 
源代码7 项目: COCOFramework   文件: AdapterViewFragment.java
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;
}
 
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;
}
 
源代码9 项目: Stringlate   文件: ActivityUtils.java
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();
}
 
源代码10 项目: DropDownMenu   文件: ItemViewHolder.java
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;
}
 
源代码11 项目: epoxy   文件: TestFieldPropChildViewModel_.java
@Nullable
public View.OnClickListener value() {
  return value_OnClickListener;
}
 
源代码12 项目: EasyAbout   文件: AboutItem.java
public View.OnClickListener getOnClickListener() {
    return onClickListener;
}
 
源代码13 项目: spanner   文件: SampleJavaActivity.java
@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);
}
 
源代码14 项目: green_android   文件: UI.java
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;
}
 
源代码15 项目: navigation-widgets   文件: NavigationDefaults.java
public NavigationDefaults navigationIconListener(View.OnClickListener listener) {
    this.navigationIconListener = listener == null ? DUMMY_NAV_ICON_LISTENER : listener;
    return this;
}
 
源代码16 项目: TutoShowcase   文件: TutoShowcase.java
public TutoShowcase onClickContentView(@IdRes int viewId, View.OnClickListener onClickListener) {
    return tutoShowcase.onClickContentView(viewId, onClickListener);
}
 
源代码17 项目: MaterialDesignLibrary   文件: Dialog.java
public void setOnAcceptButtonClickListener(
		View.OnClickListener onAcceptButtonClickListener) {
	this.onAcceptButtonClickListener = onAcceptButtonClickListener;
	if(buttonAccept != null)
		buttonAccept.setOnClickListener(onAcceptButtonClickListener);
}
 
源代码18 项目: dhis2-android-capture-app   文件: PeriodDialog.java
public PeriodDialog setNegativeListener(View.OnClickListener listener) {
    this.negativeListener = listener;
    return this;
}
 
public void setMenuTogglerListener(View.OnClickListener menuTogglerListener) {
    mMenuTogglerListener = menuTogglerListener;
}
 
源代码20 项目: KUtils-master   文件: DialogUIUtils.java
/**
 * 展示一个仅有一个按钮的对话框  仿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();
}
 
 方法所在类
 同类方法