本文整理了Java中android.widget.Button.setOnClickListener()
方法的一些代码示例,展示了Button.setOnClickListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.setOnClickListener()
方法的具体详情如下:
包路径:android.widget.Button
类名称:Button
方法名:setOnClickListener
暂无
代码示例来源:origin: stackoverflow.com
public class StartFragment extends Fragment implements OnClickListener{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_start, container, false);
Button b = (Button) v.findViewById(R.id.StartButton);
b.setOnClickListener(this);
return v;
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.StartButton:
...
break;
}
}
}
代码示例来源:origin: stackoverflow.com
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
final View view = inflater.inflate(R.layout..., container, false);
Button button = view.findViewById(R.id...);
button.setOnClickListener(...);
return view;
}
代码示例来源:origin: stackoverflow.com
Button mButton;
EditText mEdit;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mButton = (Button)findViewById(R.id.button);
mEdit = (EditText)findViewById(R.id.edittext);
mButton.setOnClickListener(
new View.OnClickListener()
{
public void onClick(View view)
{
Log.v("EditText", mEdit.getText().toString());
}
});
}
代码示例来源:origin: guardianproject/haven
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(layoutResId, container, false);
((TextView)view.findViewById(R.id.custom_slide_big_text)).setText(mTitle);
if (mButtonText != null)
{
Button button = view.findViewById(R.id.custom_slide_button);
button.setVisibility(View.VISIBLE);
button.setText(mButtonText);
button.setOnClickListener(mButtonListener);
}
return view;
}
}
代码示例来源:origin: stackoverflow.com
btn.setOnClickListener(this);
protected void onPostExecute(String result) {
TextView txt = (TextView) findViewById(R.id.output);
txt.setText("Executed"); // txt.setText(result);
代码示例来源:origin: stackoverflow.com
et = (EditText) findViewById(R.id.et);
tv = (TextView) findViewById(R.id.tv);
tv.setText("The name of our country is Bangladesh. Bangladesh is a land of rivers.");
next.setOnClickListener(new OnClickListener() {
tv.setText("The name of our country is Bangladesh. Bangladesh is a land of rivers.");
String ett =et.getText().toString();
String tvt =tv.getText().toString();
tv.setText(WordtoSpan, TextView.BufferType.SPANNABLE);
代码示例来源:origin: stackoverflow.com
public class PresentActivity extends Activity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.content_layout_id);
final Button button = (Button) findViewById(R.id.button_id);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
Intent activityChangeIntent = new Intent(PresentActivity.this, NextActivity.class);
// currentContext.startActivity(activityChangeIntent);
PresentActivity.this.startActivity(activityChangeIntent);
}
});
}
}
代码示例来源:origin: stackoverflow.com
button = (Button) findViewById(R.id.button);
etMsg = (EditText)findViewById(R.id.etMsg);
button.setOnClickListener(new OnClickListener() {
text.setText(mIRemoteService.getMessage(etMsg.getText().toString()));
} catch (RemoteException e) {
e.printStackTrace();
protected void onStart() {
super.onStart();
bindService(new Intent(Client.this, Server.class), mConnection, BIND_AUTO_CREATE);
代码示例来源:origin: Bigkoo/Android-PickerView
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
btnShow = (Button) mView.findViewById(R.id.btn_show);
btnShow.setOnClickListener(this);
mFrameLayout = (FrameLayout) mView.findViewById(R.id.fragmen_fragment);
initTimePicker();
}
代码示例来源:origin: stackoverflow.com
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class FirstActivity extends RootActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = (TextView) findViewById(R.id.tvTitle);
tv.setText("First Activity");
Button bt = (Button) findViewById(R.id.buttonNext);
bt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(FirstActivity.this, SecondActivity.class);
startActivity(i);
}
});
}
}
代码示例来源:origin: stackoverflow.com
TextView txtName = (TextView) convertView.findViewById(R.id.nameEdit);
txtName.setText(score.getName());
Button b = (Button)convertView.findViewById(R.id.deletePlayer);
b.setTag(position);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
代码示例来源:origin: ankidroid/Anki-Android
/**
* @param layoutTools to create the button
* @param p Button to load pronunciation from Beolingus
*/
private void createPronounceButton(LinearLayout layoutTools, LayoutParams p) {
Button btnPronounce = new Button(mActivity);
btnPronounce.setText(gtxt(R.string.multimedia_editor_text_field_editing_say));
btnPronounce.setOnClickListener(v -> {
String source = mEditText.getText().toString();
if (source.length() == 0) {
showToast(gtxt(R.string.multimedia_editor_text_field_editing_no_text));
return;
}
Intent intent = new Intent(mActivity, LoadPronounciationActivity.class);
intent.putExtra(LoadPronounciationActivity.EXTRA_SOURCE, source);
mActivity.startActivityForResultWithoutAnimation(intent, REQUEST_CODE_PRONOUNCIATION);
});
layoutTools.addView(btnPronounce, p);
}
代码示例来源:origin: stackoverflow.com
View v = inflater.inflate(R.layout.player_password, container, false);
passwordEdit = (EditText)v.findViewById(R.id.player_password_edit);
okButton = (Button)v.findViewById(R.id.ok_button);
okButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
passwordEntered();
playerListFragment.joinPlayer(toJoin, passwordEdit.getText().toString());
dismiss();
代码示例来源:origin: stackoverflow.com
final AlertDialog dialog = new AlertDialog.Builder(context)
.setView(v)
.setTitle(R.string.my_title)
.setPositiveButton(android.R.string.ok, null) //Set to null. We override the onclick
.setNegativeButton(android.R.string.cancel, null)
.create();
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// TODO Do something
//Dismiss once everything is OK.
dialog.dismiss();
}
});
}
});
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent,
Bundle savedInstanceState) {
View result=inflater.inflate(R.layout.main, parent, false);
b=(Button)result.findViewById(R.id.button);
b.setOnClickListener(this);
return(result);
}
代码示例来源:origin: stackoverflow.com
if (view == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.my_custom_list_layout, null);
TextView listItemText = (TextView)view.findViewById(R.id.list_item_string);
listItemText.setText(list.get(position));
Button deleteBtn = (Button)view.findViewById(R.id.delete_btn);
Button addBtn = (Button)view.findViewById(R.id.add_btn);
deleteBtn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
addBtn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
代码示例来源:origin: k9mail/k-9
private void displayAttachmentInformation() {
viewButton = findViewById(R.id.view);
downloadButton = findViewById(R.id.download);
if (attachment.size > K9.MAX_ATTACHMENT_DOWNLOAD_SIZE) {
viewButton.setVisibility(View.GONE);
downloadButton.setVisibility(View.GONE);
}
viewButton.setOnClickListener(this);
downloadButton.setOnClickListener(this);
TextView attachmentName = findViewById(R.id.attachment_name);
attachmentName.setText(attachment.displayName);
setAttachmentSize(attachment.size);
refreshThumbnail();
}
代码示例来源:origin: k9mail/k-9
mSubscribedFoldersOnly = findViewById(R.id.subscribed_folders_only);
mNextButton.setOnClickListener(this);
serverLabelView.setText(R.string.account_setup_incoming_pop_server_label);
findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE);
findViewById(R.id.webdav_advanced_header).setVisibility(View.GONE);
mSubscribedFoldersOnly.setVisibility(View.GONE);
} else if (settings.type.equals(Protocols.IMAP)) {
serverLabelView.setText(R.string.account_setup_incoming_imap_server_label);
serverLabelView.setText(R.string.account_setup_incoming_webdav_server_label);
mConnectionSecurityChoices = new ConnectionSecurity[] {
ConnectionSecurity.NONE,
updatePortFromSecurityType();
mCurrentPortViewSetting = mPortView.getText().toString();
代码示例来源:origin: stackoverflow.com
btnShow.setOnClickListener(new View.OnClickListener() {
Intent intent = new Intent("com.rj.notitfications.SECACTIVITY");
btnClear.setOnClickListener(new View.OnClickListener() {
代码示例来源:origin: stackoverflow.com
datePickerButton.setOnClickListener(new OnClickListener() {
timePickerButton.setOnClickListener(new OnClickListener() {
cancelButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
resetButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
submitButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String titleString = mTitleText.getText().toString();
c.get(Calendar.YEAR));
dateView.setText(dateString);
timeView.setText(timeString);
setDateString(dayOfMonth, monthOfYear, year);
dateView.setText(dateString);
内容来源于网络,如有侵权,请联系作者删除!