当前位置: 首页>>代码示例>>Java>>正文


Java View.OnClickListener方法代码示例

本文整理汇总了Java中android.view.View.OnClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java View.OnClickListener方法的具体用法?Java View.OnClickListener怎么用?Java View.OnClickListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.OnClickListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: AllAppsGridAdapter

import android.view.View; //导入方法依赖的package包/类
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));
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:23,代码来源:AllAppsGridAdapter.java

示例2: touchOutsideDontDisMiss

import android.view.View; //导入方法依赖的package包/类
/**
 * 点击 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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:MainActivity.java

示例3: clickable

import android.view.View; //导入方法依赖的package包/类
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;
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:14,代码来源:SpannableBuilder.java

示例4: onClickAddToCart

import android.view.View; //导入方法依赖的package包/类
@NonNull
private View.OnClickListener onClickAddToCart(){
    return new View.OnClickListener(){
        @Override
        public void onClick( View v ){
            if( listener != null ){
                listener.onClickAddToCart( BeerProductHolder.this, getAdapterPosition() );
            }
            toggleButton();
        }
    };
}
 
开发者ID:TheKhaeng,项目名称:nongbeer-mvp-android-demo,代码行数:13,代码来源:BeerProductHolder.java

示例5: onClick2

import android.view.View; //导入方法依赖的package包/类
@NonNull
private View.OnClickListener onClick2(){
    return new View.OnClickListener(){
        @Override
        public void onClick( View v ){
            if( listener != null ){
                listener.onClick2( CustomHolder.this, getAdapterPosition() );
            }
        }
    };
}
 
开发者ID:TheKhaeng,项目名称:nongbeer-mvp-android-demo,代码行数:12,代码来源:CustomHolder.java

示例6: setOnClickListener

import android.view.View; //导入方法依赖的package包/类
/**
 * 关于事件的
 */
public ViewHolder setOnClickListener(int viewId,
                                     View.OnClickListener listener)
{
    View view = getView(viewId);
    view.setOnClickListener(listener);
    return this;
}
 
开发者ID:pao11,项目名称:BaseAdapterRel,代码行数:11,代码来源:ViewHolder.java

示例7: onClick3

import android.view.View; //导入方法依赖的package包/类
@NonNull
private View.OnClickListener onClick3(){
    return new View.OnClickListener(){
        @Override
        public void onClick( View v ){
            if( listener != null ){
                listener.onClick3( CustomHolder.this, getAdapterPosition() );
            }
        }
    };
}
 
开发者ID:TheKhaeng,项目名称:nongbeer-mvp-android-demo,代码行数:12,代码来源:CustomHolder.java

示例8: setAction

import android.view.View; //导入方法依赖的package包/类
/**
 * 设置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;
}
 
开发者ID:RockyQu,项目名称:MVVMFrames,代码行数:22,代码来源:ToastBar.java

示例9: setOnClickListener

import android.view.View; //导入方法依赖的package包/类
@Override
public EasyLVHolder setOnClickListener(int viewId, View.OnClickListener listener) {
    View view = getView(viewId);
    view.setOnClickListener(listener);
    return this;
}
 
开发者ID:ynztlxdeai,项目名称:TextReader,代码行数:7,代码来源:EasyLVHolder.java

示例10: setPositiveButton

import android.view.View; //导入方法依赖的package包/类
public Builder setPositiveButton(CharSequence text, final View.OnClickListener listener) {
	mPositiveButtonText = text;
	mPositiveButtonListener = listener;
	return this;
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:6,代码来源:BaseDialogFragment.java

示例11: setupToolbar

import android.view.View; //导入方法依赖的package包/类
protected void setupToolbar(Toolbar mToolbar, boolean homeIconVisible, View.OnClickListener onBackListener) {
    setupToolbar(mToolbar, homeIconVisible);
    this.onBackListener = onBackListener;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:BaseActivity.java

示例12: addCheckbox

import android.view.View; //导入方法依赖的package包/类
public void addCheckbox(@StringRes int titleId, @StringRes int commentId, String property,
                        View.OnClickListener listener) {
    addModel(Model.CHECKBOX, getString(titleId), getString(commentId), property, listener);
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:5,代码来源:SettingsArrayAdapter.java

示例13: onCreate

import android.view.View; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:dhbw-timetable,项目名称:dhbw-timetable-android,代码行数:46,代码来源:AlarmActivity.java

示例14: onPushNotification

import android.view.View; //导入方法依赖的package包/类
private View.OnClickListener onPushNotification() {
    return view -> pushNotification(getApplicationContext());
}
 
开发者ID:akexorcist,项目名称:Android-O-Feature,代码行数:4,代码来源:NotificationChannelActivity.java

示例15: addItem

import android.view.View; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:7,代码来源:DialogBuilder.java


注:本文中的android.view.View.OnClickListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。