本文整理汇总了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));
}
示例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);
}
示例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;
}
示例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();
}
};
}
示例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() );
}
}
};
}
示例6: setOnClickListener
import android.view.View; //导入方法依赖的package包/类
/**
* 关于事件的
*/
public ViewHolder setOnClickListener(int viewId,
View.OnClickListener listener)
{
View view = getView(viewId);
view.setOnClickListener(listener);
return this;
}
示例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() );
}
}
};
}
示例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;
}
示例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;
}
示例10: setPositiveButton
import android.view.View; //导入方法依赖的package包/类
public Builder setPositiveButton(CharSequence text, final View.OnClickListener listener) {
mPositiveButtonText = text;
mPositiveButtonListener = listener;
return this;
}
示例11: setupToolbar
import android.view.View; //导入方法依赖的package包/类
protected void setupToolbar(Toolbar mToolbar, boolean homeIconVisible, View.OnClickListener onBackListener) {
setupToolbar(mToolbar, homeIconVisible);
this.onBackListener = onBackListener;
}
示例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);
}
示例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);
}
}
示例14: onPushNotification
import android.view.View; //导入方法依赖的package包/类
private View.OnClickListener onPushNotification() {
return view -> pushNotification(getApplicationContext());
}
示例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);
}