當前位置: 首頁>>代碼示例>>Java>>正文


Java Button.OnClickListener方法代碼示例

本文整理匯總了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;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:4,代碼來源:DeviceListFragment.java

示例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();
            }
        });


    }
 
開發者ID:hij2696,項目名稱:purple-05,代碼行數:54,代碼來源:MainActivity.java

示例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();

    }
 
開發者ID:efroemling,項目名稱:bombsquad-remote-android,代碼行數:44,代碼來源:GamePadActivity.java


注:本文中的android.widget.Button.OnClickListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。