本文整理了Java中android.widget.Button.setOnTouchListener()
方法的一些代码示例,展示了Button.setOnTouchListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.setOnTouchListener()
方法的具体详情如下:
包路径:android.widget.Button
类名称:Button
方法名:setOnTouchListener
暂无
代码示例来源:origin: termux/termux-app
button.setOnTouchListener((v, event) -> {
final View root = getRootView();
switch (event.getAction()) {
代码示例来源:origin: GitLqr/LQRWeChat
mBtnAudio.setOnTouchListener((v, event) -> {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
代码示例来源:origin: THEONE10211024/ApiDemos
private void setTouchFilter(Button button) {
button.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if ((event.getFlags() & MotionEvent.FLAG_WINDOW_IS_OBSCURED) != 0) {
if (event.getAction() == MotionEvent.ACTION_UP) {
new AlertDialog.Builder(SecureView.this)
.setTitle(R.string.secure_view_caught_dialog_title)
.setMessage(R.string.secure_view_caught_dialog_message)
.setNeutralButton(getResources().getString(
R.string.secure_view_caught_dialog_dismiss), null)
.show();
}
// Return true to prevent the button from processing the touch.
return true;
}
return false;
}
});
}
}
代码示例来源:origin: qiubiteme/android_api_demos
private void setTouchFilter(Button button) {
button.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if ((event.getFlags() & MotionEvent.FLAG_WINDOW_IS_OBSCURED) != 0) {
if (event.getAction() == MotionEvent.ACTION_UP) {
new AlertDialog.Builder(SecureView.this)
.setTitle(R.string.secure_view_caught_dialog_title)
.setMessage(R.string.secure_view_caught_dialog_message)
.setNeutralButton(getResources().getString(
R.string.secure_view_caught_dialog_dismiss), null)
.show();
}
// Return true to prevent the button from processing the touch.
return true;
}
return false;
}
});
}
}
代码示例来源:origin: stackoverflow.com
Button example_2 = (Button)this.findViewById(R.id.example_2);
example_1.setOnTouchListener(this);
example_2.setOnClickListener(this);
代码示例来源:origin: Michenux/YourAppIdea
@TargetApi(16)
public void setupLiveAnimOnButtonL16(final Button button, final Runnable onEndRunnable) {
button.animate().setDuration(400);
button.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
if (arg1.getAction() == MotionEvent.ACTION_DOWN) {
button.animate().setInterpolator(decelerator).
scaleX(.7f).scaleY(.7f);
} else if (arg1.getAction() == MotionEvent.ACTION_UP) {
button.animate().setInterpolator(overshooter).
scaleX(1.6f).scaleY(1.6f).withEndAction(onEndRunnable);
}
return false;
}
});
}
}
代码示例来源:origin: jaredrummler/AndroidAnimations
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button) findViewById(R.id.btn_rebound);
button.setOnTouchListener(new Rebound.SpringyTouchListener() {
@Override public void onClick(View v) {
startActivity(new Intent(MainActivity.this, ReboundDemoActivity.class));
}
});
}
代码示例来源:origin: ogarcia/opensudoku
b.setTag(num);
b.setOnClickListener(mNumberButtonClicked);
b.setOnTouchListener(mNumberButtonTouched);
代码示例来源:origin: materialos/android-icon-pack
@Override
public void onBindHeaderViewHolder(MainViewHolder holder, int section) {
final DrawableXmlParser.Category category = mFiltered != null ?
mFiltered.get(section) : mCategories.get(section);
holder.title.setText(category.getName());
if (mCategories.size() > 1 && category.size() > mIconsPerSection) {
holder.moreButton.setVisibility(View.VISIBLE);
holder.moreButton.setTag(section);
holder.moreButton.setOnTouchListener(this);
holder.moreButton.setText(holder.itemView.getContext().getString(
R.string.more_x, category.size() - mIconsPerSection));
} else {
holder.moreButton.setVisibility(View.INVISIBLE);
holder.moreButton.setTag(null);
holder.moreButton.setOnClickListener(null);
}
}
代码示例来源:origin: stackoverflow.com
sound.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
代码示例来源:origin: oliexdev/openScale
inc.setText("\u25b2 +" + formatValue(INC_DEC_DELTA));
inc.setOnClickListener(onClickListener);
inc.setOnTouchListener(repeatListener);
dec.setOnTouchListener(repeatListener);
代码示例来源:origin: bodismile/bmob-newim-demo
/**
* 初始化语音布局
* @param
* @return void
*/
private void initVoiceView() {
btn_speak.setOnTouchListener(new VoiceTouchListener());
initVoiceAnimRes();
initRecordManager();
}
代码示例来源:origin: kissonchan/ImitateAlipayPasswordInput
item.setOnTouchListener(this);
代码示例来源:origin: grzegorznittner/chanu
mUndoButton = (Button)undoView.findViewById(R.id.undo);
mUndoButton.setOnClickListener(new UndoClickListener());
mUndoButton.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
代码示例来源:origin: Car-eye-team/Car-eye-device
private void init() {
mediaPlayer = new MediaPlayer();
update = new upDateSeekBar();
setContentView(R.layout.movie_player);
backButton = (Button) findViewById(R.id.back);
menuButton = (Button) findViewById(R.id.menu);
seekbar = (SeekBar) findViewById(R.id.seekbar);
playButton = (Button) findViewById(R.id.play);
prevButton = (Button) findViewById(R.id.prev);
nextButton = (Button) findViewById(R.id.next);
pView = (SurfaceView) findViewById(R.id.mSurfaceView);
pView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
pView.getHolder().setKeepScreenOn(true);
pView.getHolder().addCallback(new surFaceView());
seekbarView = (LinearLayout) findViewById(R.id.seekbarview);
playbarView = (LinearLayout) findViewById(R.id.playbar);
mFileName = (TextView) findViewById(R.id.file_name);
mPassTime = (TextView) findViewById(R.id.pass_time);
mTotalTime = (TextView) findViewById(R.id.total_time);
view = findViewById(R.id.pb);
playButton.setOnTouchListener(this);
backButton.setOnTouchListener(this);
menuButton.setOnTouchListener(this);
prevButton.setOnTouchListener(this);
nextButton.setOnTouchListener(this);
}
代码示例来源:origin: HelloChenJinJun/TestChat
picture.setOnClickListener(this);
camera.setOnClickListener(this);
speak.setOnTouchListener(this);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
代码示例来源:origin: stackoverflow.com
if(index==3)
{
final Dialog dialog=new Dialog(Starttracker.this);
dialog.setContentView(R.layout.popup);
dialog.setTitle("Enter The Item");
dialog.setCanceledOnTouchOutside(true);
final EditText filename=(EditText)dialog.findViewById(R.id.filename);
filename.setText("");
Button d_ok=(Button)dialog.findViewById(R.id.d_ok);
Button d_cancel=(Button)dialog.findViewById(R.id.d_cancel);
d_ok.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
// TODO Auto-generated method stub
String textHolder = filename.getText().toString();
dialog.dismiss();
Items.add(textHolder);
// s1.setAdapter(adapter);
// notifyDataSetChanged();
}
});
d_cancel.setOnTouchListener(new OnTouchListener(){
public boolean onTouch(View v,MotionEvent me){
dialog.dismiss();
return false;
}
});
dialog.show();
return;
}
代码示例来源:origin: zhanyongsheng/BrokenView
public void setOnTouchListener(){
/*
if you don't want the childView of parentLayout intercept touch event
set like this:
childView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
});
childView.setClickable(false);
if you want only click the button can break the parentLayout,
set like this:
listener = new BrokenTouchListener.Builder(mBrokenView).
setEnableArea(button).
build();
and set the button don't intercept touch event at the same time
*/
parentLayout.setOnTouchListener(colorfulListener);
button.setOnTouchListener(colorfulListener);
myView.setOnTouchListener(whiteListener);
listView.setOnTouchListener(colorfulListener);
if(hasAlpha)
imageView.setOnTouchListener(whiteListener);
else
imageView.setOnTouchListener(colorfulListener);
}
代码示例来源:origin: LanSoSdk/LanSoEditor_advance
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LanSongUtil.hideBottomUIMenu(this);
setContentView(R.layout.cameralayer_fullsegment_layout);
if (LanSongUtil.checkRecordPermission(getBaseContext()) == false) {
Toast.makeText(getApplicationContext(), "请打开权限后,重试!!!",
Toast.LENGTH_LONG).show();
finish();
}
drawPadCamera = (DrawPadCameraView) findViewById(R.id.id_fullscreen_padview);
initView();
initBeautyView();
recorderVideoBtn.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
segmentStart();
break;
case MotionEvent.ACTION_UP: // 录制结束.
segmentStop();
break;
}
return true;
}
});
dstPath = LanSongFileUtil.newMp4PathInBox();
initDrawPad(); // 开始录制.
}
代码示例来源:origin: cbchena/android_examples
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this._llBtnVoice = (LinearLayout) this.findViewById(R.id.llBtnVoice);
this._btnVoice = (Button) this.findViewById(R.id.btnVoice);
this._btnVoice.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
_isBeginVocie = true; // 标志开始录音 2016/11/7 14:29
return false;
}
});
this._sensorMeter = new SoundMeter();
this._chatPopup = this.findViewById(R.id.rcChat_popup); // 录音显示UI层
this._llVoice = (LinearLayout) this.findViewById(R.id.llVoice); // 获取录音层
this._llCancelVoice = (LinearLayout) this.findViewById(R.id.del_re); // 取消录音层布局
this._imgX = (ImageView) this.findViewById(R.id.sc_img1);
this._btnModeVolume = (ImageView) this.findViewById(R.id.volume); // 显示音频大小
this._llRcdHintRcding = (LinearLayout) this
.findViewById(R.id.voice_rcd_hint_rcding); // 显示手机录音状态
this._llRcdHintLoading = (LinearLayout) this
.findViewById(R.id.voice_rcd_hint_loading); // 录音开始前的加载准备
this._llRcdHintTooshort = (LinearLayout) this
.findViewById(R.id.voice_rcd_hint_tooshort); // 显示时间太短的提示
}
内容来源于网络,如有侵权,请联系作者删除!