本文整理汇总了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();
}