本文整理匯總了Java中android.widget.Button.setOnTouchListener方法的典型用法代碼示例。如果您正苦於以下問題:Java Button.setOnTouchListener方法的具體用法?Java Button.setOnTouchListener怎麽用?Java Button.setOnTouchListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.Button
的用法示例。
在下文中一共展示了Button.setOnTouchListener方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.widget.Button; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_overshoot);
final Button clickMeButton = (Button) findViewById(R.id.clickMe);
clickMeButton.animate().setDuration(200);
clickMeButton.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
if (arg1.getAction() == MotionEvent.ACTION_DOWN) {
clickMeButton.animate().setInterpolator(sDecelerator).
scaleX(.7f).scaleY(.7f);
} else if (arg1.getAction() == MotionEvent.ACTION_UP) {
clickMeButton.animate().setInterpolator(sOvershooter).
scaleX(1f).scaleY(1f);
}
return false;
}
});
}
示例2: showWindow
import android.widget.Button; //導入方法依賴的package包/類
private void showWindow() {
mFloatingButton = new Button(this);
mFloatingButton.setText("button");
mFloatingButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "我是window", Toast.LENGTH_LONG).show();
}
});
mLayoutParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT
,WindowManager.LayoutParams.WRAP_CONTENT, 0, 0, PixelFormat.TRANSLUCENT);
mLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
mLayoutParams.gravity = Gravity.LEFT | Gravity.TOP;
mLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
mLayoutParams.x = 100;
mLayoutParams.y = 300;
mFloatingButton.setOnTouchListener(this);
mWindowManager.addView(mFloatingButton, mLayoutParams);
}
示例3: onCreate
import android.widget.Button; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
W = (Button)(findViewById(R.id.W));
E = (Button)(findViewById(R.id.E));
N = (Button)(findViewById(R.id.N));
S = (Button)(findViewById(R.id.S));
SW = (Button)(findViewById(R.id.SW));
SE = (Button)(findViewById(R.id.SE));
NE = (Button)(findViewById(R.id.NE));
NW = (Button)(findViewById(R.id.NW));
toBluetooth = (Button)(findViewById(R.id.Bluetooth));
init(set);
W.setOnTouchListener(new myHandler(1));
E.setOnTouchListener(new myHandler(2));
N.setOnTouchListener(new myHandler(3));
S.setOnTouchListener(new myHandler(4));
NE.setOnTouchListener(new myHandler(5));
NW.setOnTouchListener(new myHandler(6));
SW.setOnTouchListener(new myHandler(7));
SE.setOnTouchListener(new myHandler(8));
toBluetooth.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivityForResult(new Intent(MainActivity.this , Bluetooth.class) , 1);
}
});
}
示例4: initBottomView
import android.widget.Button; //導入方法依賴的package包/類
private void initBottomView() {
add = (Button) findViewById(R.id.btn_chat_bottom_add);
emotion = (Button) findViewById(R.id.btn_chat_bottom_emotion);
input = (EditText) findViewById(R.id.et_chat_bottom_input);
speak = (Button) findViewById(R.id.btn_chat_bottom_speak);
send = (Button) findViewById(R.id.btn_chat_bottom_send);
voice = (Button) findViewById(R.id.btn_chat_bottom_voice);
keyboard = (Button) findViewById(R.id.btn_chat_bottom_keyboard);
l1_more = (LinearLayout) findViewById(R.id.l1_chat_bottom_more);
mViewPager = (ViewPager) findViewById(R.id.vp_chat_bottom_emotion);
r1_emotion = (RelativeLayout) findViewById(R.id.r1_chat_bottom_emotion);
l1_add = (LinearLayout) findViewById(R.id.l1_chat_bottom_add);
picture = (TextView) findViewById(R.id.tv_chat_bottom_picture);
camera = (TextView) findViewById(R.id.tv_chat_bottom_camera);
location = (TextView) findViewById(R.id.tv_chat_bottom_location);
add.setOnClickListener(this);
emotion.setOnClickListener(this);
input.addTextChangedListener(this);
input.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
LogUtil.e("聚焦");
scrollToBottom();
if (l1_more.getVisibility() == View.VISIBLE) {
l1_more.setVisibility(View.GONE);
}
}
}
});
voice.setOnClickListener(this);
send.setOnClickListener(this);
keyboard.setOnClickListener(this);
location.setOnClickListener(this);
picture.setOnClickListener(this);
camera.setOnClickListener(this);
speak.setOnTouchListener(this);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mSwipeRefreshLayout.setRefreshing(true);
BaseMessage message = mAdapter.getData(0);
LoadMessage(message);
}
});
}
示例5: initUi
import android.widget.Button; //導入方法依賴的package包/類
@SuppressLint("ShowToast")
private void initUi() {
mResultEditText = (EditText) findViewById(R.id.edt_result);
mAuthidEditText = (EditText) findViewById(R.id.set_authId);
btn_start_record = (Button) findViewById(R.id.isv_reocrd);
btn_start_record.setOnTouchListener(VocalVerifyDemo.this);
findViewById(R.id.isv_getpassword).setOnClickListener(VocalVerifyDemo.this);
findViewById(R.id.isv_search).setOnClickListener(VocalVerifyDemo.this);
findViewById(R.id.isv_delete).setOnClickListener(VocalVerifyDemo.this);
findViewById(R.id.isv_identity).setOnClickListener(VocalVerifyDemo.this);
mToast = Toast.makeText(VocalVerifyDemo.this, "", Toast.LENGTH_SHORT);
mToast.setGravity(Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0);
mProDialog = new ProgressDialog(VocalVerifyDemo.this);
mProDialog.setCancelable(true);
mProDialog.setTitle("請稍候");
// cancel進度框時,取消正在進行的操作
mProDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
if (null != mIdVerifier) {
mIdVerifier.cancel();
}
}
});
// 密碼選擇RadioGroup初始化
mSstTypeGroup = (RadioGroup) findViewById(R.id.vocal_radioGroup1);
mSstTypeGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if( null == mIdVerifier ){
// 創建單例失敗,與 21001 錯誤為同樣原因,參考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
showTip( "創建對象失敗,請確認 libmsc.so 放置正確,且有調用 createUtility 進行初始化" );
return;
}
// 取消之前操作
if (mIdVerifier.isWorking()) {
mIdVerifier.cancel();
}
cancelOperation();
switch (checkedId) {
case R.id.vocal_radioVerify:
// 設置會話類型為驗證
mSST = SST_VERIFY;
mVerifyNumPwd = VerifierUtil.generateNumberPassword(8);
StringBuffer strBuffer = new StringBuffer();
strBuffer.append("您的驗證密碼:" + mVerifyNumPwd + "\n");
strBuffer.append("請長按“按住說話”按鈕進行驗證!\n");
mResultEditText.setText(strBuffer.toString());
break;
case R.id.vocal_radioEnroll:
// 設置會話類型為驗證
mSST = SST_ENROLL;
if (null == mNumPwdSegs) {
// 首次注冊密碼為空時,調用下載密碼
downloadPwd();
} else {
mResultEditText.setText("請長按“按住說話”按鈕進行注冊\n");
}
break;
default:
break;
}
}
});
}
示例6: onCreate
import android.widget.Button; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_window);
findViewById(R.id.btn_add_view).setOnClickListener(this);
findViewById(R.id.btn_remove_view).setOnClickListener(this);
windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
layoutParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT
, WindowManager.LayoutParams.WRAP_CONTENT, 0, 0, PixelFormat.TRANSLUCENT);
layoutParams.x = 100;
layoutParams.y = 100;
layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION;
button = new Button(this);
button.setText("Button");
button.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE:
if (windowManager != null) {
layoutParams.x = (int) event.getRawX();
layoutParams.y = (int) event.getRawY();
windowManager.updateViewLayout(button, layoutParams);
}
break;
}
return false;
}
});
}