本文整理匯總了Java中android.widget.Button.OnClickListener方法的典型用法代碼示例。如果您正苦於以下問題:Java Button.OnClickListener方法的具體用法?Java Button.OnClickListener怎麽用?Java Button.OnClickListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.Button
的用法示例。
在下文中一共展示了Button.OnClickListener方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setAddDeviceButtonListener
import android.widget.Button; //導入方法依賴的package包/類
public void setAddDeviceButtonListener(Button.OnClickListener listener) {
this.addDeviceButtonListener = listener;
}
示例2: onCreate
import android.widget.Button; //導入方法依賴的package包/類
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Twitter.initialize(this);
setContentView(R.layout.activity_main);
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
Button.OnClickListener onClickListener = new Button.OnClickListener() {
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.facebookLogBtn :
// 페이스북 로그인 버튼 이벤트
faceBookLogIn();
break ;
//트위터는 버튼 특성에 따라서 따로 만듬.
default:
break ;
}
}
} ;
Button btn = (Button) findViewById(R.id.facebookLogBtn);
btn.setOnClickListener(onClickListener);
//트위터 버튼 이벤트 설정
twitterLoginButton = (TwitterLoginButton) findViewById(R.id.twitterLogBtn);
twitterLoginButton.setCallback(new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
// Do something with result, which provides a TwitterSession for making API calls
TwitterSession session = TwitterCore.getInstance().getSessionManager().getActiveSession();
String userName = session.getUserName();
Intent home_view = new Intent(getApplicationContext(),HomeActivity.class);
home_view.putExtra("userName",userName);
home_view.putExtra("from", "twitter");
startActivity(home_view);
}
@Override
public void failure(TwitterException exception) {
// Do something on failure
Toast.makeText(getApplicationContext(), "아이디/비밀번호를 확인하세요.",Toast.LENGTH_SHORT).show();
}
});
}
示例3: doHardwareControlsPrefs
import android.widget.Button; //導入方法依賴的package包/類
public void doHardwareControlsPrefs() {
final Dialog d = new Dialog(_gamePadActivity);
d.setContentView(R.layout.prefs_hardware_controls);
d.setCanceledOnTouchOutside(true);
Button.OnClickListener l =
new Button.OnClickListener(){
@Override
public void onClick(View v) {
// take note of which action this capture will apply to, then launch a capture..
if (v == d.findViewById(R.id.buttonPickUp)) _captureKey = CaptureKey.PICK_UP;
else if (v == d.findViewById(R.id.buttonJump)) _captureKey = CaptureKey.JUMP;
else if (v == d.findViewById(R.id.buttonPunch)) _captureKey = CaptureKey.PUNCH;
else if (v == d.findViewById(R.id.buttonBomb)) _captureKey = CaptureKey.BOMB;
else if (v == d.findViewById(R.id.buttonRun1)) _captureKey = CaptureKey.RUN1;
else if (v == d.findViewById(R.id.buttonRun2)) _captureKey = CaptureKey.RUN2;
else if (v == d.findViewById(R.id.buttonStart)) _captureKey = CaptureKey.START;
else LogThread.log("Error: unrecognized capture button",null);
Dialog d2 = doCaptureKey();
d2.setOnDismissListener(new Dialog.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
_updateHardwareControlsLabels(d);
}
});
}};
d.findViewById(R.id.buttonPickUp).setOnClickListener(l);
d.findViewById(R.id.buttonJump).setOnClickListener(l);
d.findViewById(R.id.buttonPunch).setOnClickListener(l);
d.findViewById(R.id.buttonBomb).setOnClickListener(l);
d.findViewById(R.id.buttonRun1).setOnClickListener(l);
d.findViewById(R.id.buttonRun2).setOnClickListener(l);
d.findViewById(R.id.buttonStart).setOnClickListener(l);
d.setTitle(R.string.configHardwareButtons);
_updateHardwareControlsLabels(d);
d.show();
}