Java Code Examples for android.view.View.OnClickListener

The following are Jave code examples for showing how to use OnClickListener of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: SimpleUILauncher   File: AllAppsGridAdapter.java   View Source Code Vote up 6 votes
public AllAppsGridAdapter(Launcher launcher, AlphabeticalAppsList apps, View.OnClickListener
        iconClickListener, View.OnLongClickListener iconLongClickListener) {
    Resources res = launcher.getResources();
    mLauncher = launcher;
    mApps = apps;
    mEmptySearchMessage = res.getString(R.string.all_apps_loading_message);
    mGridSizer = new GridSpanSizer();
    mGridLayoutMgr = new AppsGridLayoutManager(launcher);
    mGridLayoutMgr.setSpanSizeLookup(mGridSizer);
    mItemDecoration = new GridItemDecoration();
    mLayoutInflater = LayoutInflater.from(launcher);
    mIconClickListener = iconClickListener;
    mIconLongClickListener = iconLongClickListener;
    mSectionNamesMargin = res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin);
    mSectionHeaderOffset = res.getDimensionPixelSize(R.dimen.all_apps_grid_section_y_offset);
    mIsRtl = Utilities.isRtl(res);

    mSectionTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mSectionTextPaint.setTextSize(res.getDimensionPixelSize(
            R.dimen.all_apps_grid_section_text_size));
    mSectionTextPaint.setColor(Utilities.getColorAccent(launcher));
}
 
Example 2
Project: GitHub   File: MainActivity.java   View Source Code Vote up 6 votes
/**
 * 点击 PopupWindow 之外的地方不消失
 */
private void touchOutsideDontDisMiss(){
    View view = LayoutInflater.from(this).inflate(R.layout.pop_layout_close,null);
    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.e("FK","onClick.....");
            mPopWindow.dissmiss();
        }
    };
    view.findViewById(R.id.close_pop).setOnClickListener(listener);
    mPopWindow = new CustomPopWindow.PopupWindowBuilder(this)
            .setView(view)
            .enableOutsideTouchableDissmiss(false)// 设置点击PopupWindow之外的地方,popWindow不关闭,如果不设置这个属性或者为true,则关闭
            .create();

    mPopWindow.showAsDropDown(mButton7,0,10);
}
 
Example 3
Project: mvvm-template   File: SpannableBuilder.java   View Source Code Vote up 5 votes
public SpannableBuilder clickable(final CharSequence text, final View.OnClickListener listener) {
    if (!InputHelper.isEmpty(text)) return append(text, new ClickableSpan() {
        @Override public void updateDrawState(TextPaint ds) {
            ds.setColor(ds.linkColor);
            ds.setUnderlineText(false);
        }

        @Override public void onClick(View widget) {
            listener.onClick(widget);
        }
    });
    return this;
}
 
Example 4
Project: nongbeer-mvp-android-demo   File: BeerProductHolder.java   View Source Code Vote up 5 votes
@NonNull
private View.OnClickListener onClickAddToCart(){
    return new View.OnClickListener(){
        @Override
        public void onClick( View v ){
            if( listener != null ){
                listener.onClickAddToCart( BeerProductHolder.this, getAdapterPosition() );
            }
            toggleButton();
        }
    };
}
 
Example 5
Project: nongbeer-mvp-android-demo   File: CustomHolder.java   View Source Code Vote up 5 votes
@NonNull
private View.OnClickListener onClick2(){
    return new View.OnClickListener(){
        @Override
        public void onClick( View v ){
            if( listener != null ){
                listener.onClick2( CustomHolder.this, getAdapterPosition() );
            }
        }
    };
}
 
Example 6
Project: BaseAdapterRel   File: ViewHolder.java   View Source Code Vote up 5 votes
/**
 * 关于事件的
 */
public ViewHolder setOnClickListener(int viewId,
                                     View.OnClickListener listener)
{
    View view = getView(viewId);
    view.setOnClickListener(listener);
    return this;
}
 
Example 7
Project: nongbeer-mvp-android-demo   File: CustomHolder.java   View Source Code Vote up 5 votes
@NonNull
private View.OnClickListener onClick3(){
    return new View.OnClickListener(){
        @Override
        public void onClick( View v ){
            if( listener != null ){
                listener.onClick3( CustomHolder.this, getAdapterPosition() );
            }
        }
    };
}
 
Example 8
Project: MVVMFrames   File: ToastBar.java   View Source Code Vote up 5 votes
/**
 * 设置Button文字内容、颜色、点击事件
 *
 * @param message
 * @param color
 * @param onClickListener
 * @return ToastBar
 */
public ToastBar setAction(String message, @ColorInt int color, View.OnClickListener onClickListener) {
    Button button = (Button) snackbar.getView().findViewById(R.id.snackbar_action);
    if (!TextUtils.isEmpty(message)) {
        button.setText(message);
    }
    if (color != 0) {
        button.setTextColor(color);
    }
    if (onClickListener != null) {
        button.setOnClickListener(onClickListener);
    }
    return this;
}
 
Example 9
Project: TextReader   File: EasyLVHolder.java   View Source Code Vote up 4 votes
@Override
public EasyLVHolder setOnClickListener(int viewId, View.OnClickListener listener) {
    View view = getView(viewId);
    view.setOnClickListener(listener);
    return this;
}
 
Example 10
Project: Huochexing12306   File: BaseDialogFragment.java   View Source Code Vote up 4 votes
public Builder setPositiveButton(CharSequence text, final View.OnClickListener listener) {
	mPositiveButtonText = text;
	mPositiveButtonListener = listener;
	return this;
}
 
Example 11
Project: GitHub   File: BaseActivity.java   View Source Code Vote up 4 votes
protected void setupToolbar(Toolbar mToolbar, boolean homeIconVisible, View.OnClickListener onBackListener) {
    setupToolbar(mToolbar, homeIconVisible);
    this.onBackListener = onBackListener;
}
 
Example 12
Project: BlackList   File: SettingsArrayAdapter.java   View Source Code Vote up 4 votes
public void addCheckbox(@StringRes int titleId, @StringRes int commentId, String property,
                        View.OnClickListener listener) {
    addModel(Model.CHECKBOX, getString(titleId), getString(commentId), property, listener);
}
 
Example 13
Project: dhbw-timetable-android   File: AlarmActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i("ALARM-ACT", "Creating alarm activity.");
    setContentView(R.layout.alarm);

    Button snoozeBtn = (Button) findViewById(R.id.snoozeButton);
    Button stopBtn = (Button) findViewById(R.id.alarmStopButton);

    snoozeBtn.setOnClickListener(v -> {
        destroy = false;
        finish();
    });

    View.OnClickListener stopAlarm = v -> {
        destroy = true;
        finish();
    };

    stopBtn.setOnClickListener(stopAlarm);

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

    BackportAppointment appointment = AlarmSupervisor.getInstance().getCurrentAppointment(getApplication());
    if (appointment != null) {
        title = appointment.getTitle();
        time = appointment.getStartTime();

        // If appointment is already over for five minutes, stop alarm
        if (appointment.getStartDate().getTimeInMillis() < System.currentTimeMillis() - (1000 * 60 * 5)) {
            Log.w("ALARM", "Missed an alarm for appointment " + title + " at " + time);
            stopAlarm.onClick(null);
        }

        TextView alarmTextInfo = (TextView) findViewById(R.id.alarmTextInfo);
        alarmTextInfo.setText(String.format("%s at %s", title, time));


    } else {
        Log.w("ALARM", "Tried launching alarm activity without appointment! :((");
        stopAlarm.onClick(null);
    }
}
 
Example 14
Project: Android-O-Feature   File: NotificationChannelActivity.java   View Source Code Vote up 4 votes
private View.OnClickListener onPushNotification() {
    return view -> pushNotification(getApplicationContext());
}
 
Example 15
Project: BlackList   File: DialogBuilder.java   View Source Code Vote up 4 votes
/**
 * Adds the new item to the list with title and click listener
 **/
public DialogBuilder addItem(@StringRes int titleId, View.OnClickListener listener) {
    return addItem(-1, titleId, null, listener);
}
 
Example 16
Project: AndroidBackendlessChat   File: ChatSDKProfileHelper.java   View Source Code Vote up 4 votes
public static View.OnClickListener getPickImageClickListener(final FragmentActivity activity,final DialogFragment fragment, final int requestCode){
    return ChatSDKIntentClickListener.getPickImageClickListener(activity, fragment, requestCode);
}
 
Example 17
Project: TestChat   File: ToolBarOption.java   View Source Code Vote up 4 votes
public void setRightListener(View.OnClickListener rightListener) {
        this.rightListener = rightListener;
}
 
Example 18
Project: SuperRecyclerViewAdapter   File: SuperRecyclerHolder.java   View Source Code Vote up 4 votes
public SuperRecyclerHolder setOnClickListenner(@IdRes int viewId,
    @Nullable View.OnClickListener listener) {
    retrieveView(viewId).setOnClickListener(listener);
    return this;
}
 
Example 19
Project: RLibrary   File: UIItemDialog.java   View Source Code Vote up 4 votes
public ItemInfo setClickListener(View.OnClickListener clickListener) {
    mClickListener = clickListener;
    return this;
}
 
Example 20
Project: MaterialAbout   File: AboutBuilder.java   View Source Code Vote up 2 votes
/**
 * Adds an link on the links section.
 *
 * @param icon            the action icon
 * @param label           the action title
 * @param onClickListener the click callback
 * @return the same {@link AboutBuilder} instance
 */
public AboutBuilder addLink(BitmapDrawable icon, String label, View.OnClickListener onClickListener) {
    return addLink(IconUtil.getBitmap(icon), label, onClickListener);
}