当前位置: 首页>>代码示例>>Java>>正文


Java Button.setOnClickListener方法代码示例

本文整理汇总了Java中android.widget.Button.setOnClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setOnClickListener方法的具体用法?Java Button.setOnClickListener怎么用?Java Button.setOnClickListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.Button的用法示例。


在下文中一共展示了Button.setOnClickListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createGoToEndButton

import android.widget.Button; //导入方法依赖的package包/类
/**
 * Creates a button which can be clicked to go to the end of the test view.
 *
 * @return the button, not null
 */
private Button createGoToEndButton() {
	final Button b = new Button(this);
	b.setText("Go to end");
	b.setAllCaps(false);

	b.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(final View v) {
			final int endIndex = getTestView().getItems().size() - 1;
			getTestView().showItem(endIndex);
		}
	});

	return b;
}
 
开发者ID:MatthewTamlin,项目名称:Mixtape,代码行数:21,代码来源:BodyViewTestHarness.java

示例2: init

import android.widget.Button; //导入方法依赖的package包/类
private void init(final Context context, AttributeSet attrs) {
    this.context = context;
    LayoutInflater.from(context).inflate(R.layout.chat_primary_menu, this);
    editText = (EditText) findViewById(R.id.et_sendmessage);
    buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard);
    edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout);
    buttonSetModeVoice = findViewById(R.id.btn_set_mode_voice);
    buttonSend = findViewById(R.id.btn_send);
    buttonPressToSpeak = findViewById(R.id.btn_press_to_speak);
    faceNormal = (ImageView) findViewById(R.id.iv_face_normal);
    faceChecked = (ImageView) findViewById(R.id.iv_face_checked);
    faceLayout = (RelativeLayout) findViewById(R.id.rl_face);
    buttonMore = (Button) findViewById(R.id.btn_more);

    buttonSend.setOnClickListener(this);
    buttonSetModeKeyboard.setOnClickListener(this);
    buttonSetModeVoice.setOnClickListener(this);
    buttonMore.setOnClickListener(this);
    faceLayout.setOnClickListener(this);
    editText.setOnClickListener(this);
    editText.requestFocus();

    // 监听文字框
    editText.addTextChangedListener(new EdittextWatcher(){
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (!TextUtils.isEmpty(s)) {
                buttonMore.setVisibility(View.GONE);
                buttonSend.setVisibility(View.VISIBLE);
            } else {
                buttonMore.setVisibility(View.VISIBLE);
                buttonSend.setVisibility(View.GONE);
            }
        }
    });

    buttonPressToSpeak.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if(listener != null){
                return listener.onPressToSpeakBtnTouch(v, event);
            }
            return false;
        }
    });
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:48,代码来源:ChatPrimaryMenuLayout.java

示例3: onCreate

import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_example);
    btn = (Button) findViewById(R.id.btn);
    textView = (TextView) findViewById(R.id.textView);

    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            doSomeWork();
        }
    });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:DebounceExampleActivity.java

示例4: initViews

import android.widget.Button; //导入方法依赖的package包/类
/**
 * Initializes views, sets onClick listeners and sets font style.
 */
private void initViews() {
    deviceConnectionStatusBtn = (Button) findViewById(R.id.connected_device_status_button);
    bottomPairButton = (LinearLayout) findViewById(R.id.ll_pairing_activity_screen);
    pairButtonView = (LinearLayout) findViewById(R.id.pairButtonView);
    pairTipView = (LinearLayout) findViewById(R.id.pairTipView);
    connectDeviceView = findViewById(R.id.connectDeviceView);
    newDeviceView = (LinearLayout) findViewById(R.id.newDeviceView);
    pairSearchView = (LinearLayout) findViewById(R.id.pairSearchView);

    //Setup on click listeners.
    deviceConnectionStatusBtn.setOnClickListener(this);
    findViewById(R.id.pairButton).setOnClickListener(this);
    findViewById(R.id.cancel_tip_step_1_btn).setOnClickListener(this);
    findViewById(R.id.ok_enter_pattern_step_2_btn).setOnClickListener(this);
    findViewById(R.id.cancel_enter_pattern_step_2_btn).setOnClickListener(this);
    findViewById(R.id.cancel_search_microbit_step_3_btn).setOnClickListener(this);

    setupFontStyle();
}
 
开发者ID:Samsung,项目名称:microbit,代码行数:23,代码来源:PairingActivity.java

示例5: setupViews

import android.widget.Button; //导入方法依赖的package包/类
private void setupViews() {
    textInput_nom      = (TextInputLayout) findViewById(R.id.textInput_nom);
    textInput_email    = (TextInputLayout) findViewById(R.id.textInput_email);
    textInput_addresse = (TextInputLayout) findViewById(R.id.textInput_Adresse);
    textInput_mobile   = (TextInputLayout) findViewById(R.id.textInput_mobile);
    textInput_tel      = (TextInputLayout) findViewById(R.id.textInput_telephone);
    checkBox_sms       = (CheckBox) findViewById(R.id.checkBox_canReceiveSMS);
    spinner_titre      = (Spinner) findViewById(R.id.spinner_titre);
    Button button_ajouter = (Button) findViewById(R.id.button_ajouter);
    button_ajouter.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if(!checkFields())
                Toast.makeText(AjouteClientActivity.this, "Erreur", Toast.LENGTH_SHORT).show();
            else
                addClient();
        }
    });
}
 
开发者ID:ayounes3333,项目名称:GSB-2017-Android,代码行数:20,代码来源:AjouteClientActivity.java

示例6: addButton

import android.widget.Button; //导入方法依赖的package包/类
public void addButton(String text) {
    Button button = new Button(getContext());
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-2, -1);
    button.setText(text);
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (commonCallBack != null) {
                int index = mLinearLayout.indexOfChild(v);
                commonCallBack.onEvent(index);
            }
        }
    });
    mLinearLayout.addView(button, params);
    mTimer.schedule(new TimerTask() {
        @Override
        public void run() {
            fullScroll(FOCUS_RIGHT);
        }
    }, 100L);
}
 
开发者ID:Fansvaer,项目名称:LuPengWeather,代码行数:22,代码来源:PagerIndecator.java

示例7: initView

import android.widget.Button; //导入方法依赖的package包/类
private void initView() {
  	sendButton = findView(R.id.action_bar_right_clickable_textview);
sendButton.setText(R.string.send);
sendButton.setOnClickListener(this);
  	sendButton.setVisibility(View.INVISIBLE);
  	
  	pinView = (ImageView) findViewById(R.id.location_pin);
  	pinInfoPanel = findViewById(R.id.location_info);
  	pinInfoTextView = (TextView) pinInfoPanel.findViewById(R.id.marker_address);

  	pinView.setOnClickListener(this);
  	pinInfoPanel.setOnClickListener(this);
  	
  	
  	btnMyLocation = (Button) findViewById(R.id.my_location);
  	btnMyLocation.setOnClickListener(this);
  	btnMyLocation.setVisibility(View.GONE);
  }
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:19,代码来源:LocationAmapActivity.java

示例8: assignments

import android.widget.Button; //导入方法依赖的package包/类
@Override
public void assignments(View view) {
    btn_next = (Button) view.findViewById(R.id.btn_next);
    btn_next.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            accionBotonSiguiente();
        }
    });
}
 
开发者ID:pegasus1992,项目名称:OracionesCatolicas,代码行数:11,代码来源:PadreNuestroFragment.java

示例9: createHideHeaderAlwaysButton

import android.widget.Button; //导入方法依赖的package包/类
/**
 * Creates a button which can be clicked to configure the test view to always hide the header.
 *
 * @return the button, not null
 */
private Button createHideHeaderAlwaysButton() {
	final Button b = new Button(this);
	b.setText("Hide header always");
	b.setAllCaps(false);

	b.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			testView.hideHeaderAlways();
		}
	});

	return b;
}
 
开发者ID:MatthewTamlin,项目名称:Mixtape,代码行数:20,代码来源:CoordinatedMixtapeContainerTestHarness.java

示例10: AvatarVH

import android.widget.Button; //导入方法依赖的package包/类
public AvatarVH(View itemView) {
    super(itemView);
    imageView = (ImageView) itemView.findViewById(R.id.imageView);
    layout = (FrameLayout) itemView.findViewById(R.id.layout);
    tv = (TextView) itemView.findViewById(R.id.tv);
    btnDelete = (Button) itemView.findViewById(R.id.btnDelete);
    btnDelete.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onItemDismiss(getLayoutPosition());
        }
    });
}
 
开发者ID:ATHBK,项目名称:AvatarTinderView,代码行数:14,代码来源:AvatarAdapter.java

示例11: onActivityCreated

import android.widget.Button; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    
    Button logoutButton = (Button) getView().findViewById(R.id.btn_logout);
    logoutButton.setOnClickListener(new OnClickListener() {
        
        @Override
        public void onClick(View v) {
            EMClient.getInstance().logout(false, new EMCallBack() {
                
                @Override
                public void onSuccess() {
                    getActivity().finish();
                    startActivity(new Intent(getActivity(), LoginActivity.class));
                }
                
                @Override
                public void onProgress(int progress, String status) {
                    
                }
                
                @Override
                public void onError(int code, String error) {
                    
                }
            });
        }
    });
}
 
开发者ID:Vicent9920,项目名称:FanChat,代码行数:31,代码来源:SettingsFragment.java

示例12: onCreate

import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    submitButton=(Button) findViewById(R.id.bt_submit_order);
    confirmButton=(Button) findViewById(R.id.bt_corfirm);
    textView=(TextView) findViewById(R.id.tv_prepay_id);
    submitButton.setOnClickListener(this);
    confirmButton.setOnClickListener(this);
    sb=new StringBuffer();
    req=new PayReq();
}
 
开发者ID:gyqGitHub,项目名称:WeiXinPayDemo,代码行数:13,代码来源:MainActivity.java

示例13: onViewCreated

import android.widget.Button; //导入方法依赖的package包/类
@Override public void onViewCreated(final View view, final Bundle savedInstanceState) {
  textureView = (AutoFitTextureView) view.findViewById(R.id.texture);
  buttonTakePhoto = (Button) view.findViewById(R.id.bt_shoot);
  buttonTakePhoto.setOnClickListener(takeSnapshotListener);

  toggleButton = (ImageButton) view.findViewById(R.id.bt_toggle);
  toggleButton.setOnClickListener(new View.OnClickListener() {
    @Override public void onClick(View v) {
      toggleFacing();
    }
  });
}
 
开发者ID:flipper83,项目名称:SortingHatAndroid,代码行数:13,代码来源:CameraConnectionFragment.java

示例14: onCreate

import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    verifyStoragePermissions(this);
    setContentView(R.layout.activity_parse_xml);
    mDoParse = (Button)findViewById(R.id.parse);
    mLinearLayout = (LinearLayout)findViewById(R.id.container);
    mDoParse.setOnClickListener(this);
}
 
开发者ID:alibaba,项目名称:Virtualview-Android,代码行数:10,代码来源:ParserDemoActivity.java

示例15: onCreate

import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    initProgressDialog();
    Button btn = (Button) findViewById(R.id.btn);
    btn.setOnClickListener(this);
}
 
开发者ID:ferozbaig96,项目名称:VolleySimple,代码行数:12,代码来源:MainActivity.java


注:本文中的android.widget.Button.setOnClickListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。