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