當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。