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


Java Button類代碼示例

本文整理匯總了Java中android.widget.Button的典型用法代碼示例。如果您正苦於以下問題:Java Button類的具體用法?Java Button怎麽用?Java Button使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Button類屬於android.widget包,在下文中一共展示了Button類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import android.widget.Button; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.title_editor);

    // Get the uri of the note whose title we want to edit
    mUri = getIntent().getData();

    // Get a cursor to access the note
    mCursor = managedQuery(mUri, PROJECTION, null, null, null);

    // Set up click handlers for the text field and button
    mText = (EditText) this.findViewById(R.id.title);
    mText.setOnClickListener(this);
    
    Button b = (Button) findViewById(R.id.ok);
    b.setOnClickListener(this);
}
 
開發者ID:firebase,項目名稱:firebase-testlab-instr-lib,代碼行數:20,代碼來源:TitleEditor.java

示例2: RunwiseDialog

import android.widget.Button; //導入依賴的package包/類
@Inject
public RunwiseDialog(@ActivityContext Context context) {
	super(context, R.style.CustomProgressDialog);
	setContentView(R.layout.dialog_layout);
	Window window = getWindow();
	window.getAttributes().gravity = Gravity.CENTER;
		window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	this.setCancelable(true);
	this.setCanceledOnTouchOutside(false);
	this.context = (TextView) this.findViewById(R.id.context);
       cancle = (Button) this.findViewById(R.id.cancle);
	okBtn = (Button) this.findViewById(R.id.ok);
	vLine = this.findViewById(R.id.vline);
	hLine = this.findViewById(R.id.hline);
	title = (TextView) this.findViewById(R.id.title);
	btnLayout = (LinearLayout) this.findViewById(R.id.dialog_btn_layout);
	setLeftBtnListener("取消",null);
}
 
開發者ID:ebridfighter,項目名稱:GongXianSheng,代碼行數:19,代碼來源:RunwiseDialog.java

示例3: convert

import android.widget.Button; //導入依賴的package包/類
@Override
protected void convert(BaseViewHolder viewHolder, final Wares wares) {
    SimpleDraweeView draweeView = (SimpleDraweeView) viewHolder.getView(R.id.drawee_view);
    draweeView.setImageURI(Uri.parse(wares.getImgUrl()));

    viewHolder.getTextView(R.id.text_title).setText(wares.getName());
    viewHolder.getTextView(R.id.text_price).setText("¥ "+wares.getPrice());

    Button button =viewHolder.getButton(R.id.btn_add);
    if(button !=null) {
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                provider.put(wares);

                ToastUtils.show(context, "已添加到購物車");
            }
        });
    }

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:HWAdatper.java

示例4: onSuccess

import android.widget.Button; //導入依賴的package包/類
@Override
        public void onSuccess(com.facebook.login.LoginResult loginResult) {
            Profile facebookProfile = Profile.getCurrentProfile();
            if (facebookProfile == null) {
                String errorMsg = InfoFromFacebookActivity.this.getResources().getString(R.string.facebook_error);
                errorMsg = errorMsg + ".";
                Snackbar.make(textViewFacebookName, errorMsg, Snackbar.LENGTH_LONG).show();
                textViewFacebookName.setText(errorMsg);
            } else {
                facebookProfilePhoto.setProfileId(facebookProfile.getId());
                textViewFacebookName.setText(facebookProfile.getName());

                buttonAck.setEnabled(true);
                buttonSwitch.setVisibility(Button.VISIBLE);
            }

            // TODO: Do not store access token - it is a security issue storing this
            // TODO and appears to be of no benefit.
//                AccessToken token = loginResult.getAccessToken();
//                DataHolder data = DataHolder.getInstance(InfoFromFacebookActivity.this.getApplicationContext());
//                data.setFacebookToken(token.getToken());
//                data.persist();
        }
 
開發者ID:nelladragon,項目名稱:scab,代碼行數:24,代碼來源:InfoFromFacebookActivity.java

示例5: showAbout

import android.widget.Button; //導入依賴的package包/類
/**
 * Display About dialog
 */
private void showAbout() {
    final AlertDialog dialog = showAlert(MainActivity.this,
            getString(R.string.app_name),
            R.layout.about,
            R.drawable.ic_ulogger_logo_24dp);
    final TextView versionLabel = (TextView) dialog.findViewById(R.id.about_version);
    versionLabel.setText(getString(R.string.about_version, BuildConfig.VERSION_NAME));
    final TextView descriptionLabel = (TextView) dialog.findViewById(R.id.about_description);
    final TextView description2Label = (TextView) dialog.findViewById(R.id.about_description2);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
        descriptionLabel.setText(fromHtmlDepreciated(getString(R.string.about_description)));
        description2Label.setText(fromHtmlDepreciated(getString(R.string.about_description2)));
    } else {
        descriptionLabel.setText(Html.fromHtml(getString(R.string.about_description), android.text.Html.FROM_HTML_MODE_LEGACY));
        description2Label.setText(Html.fromHtml(getString(R.string.about_description2), android.text.Html.FROM_HTML_MODE_LEGACY));
    }
    final Button okButton = (Button) dialog.findViewById(R.id.about_button_ok);
    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
}
 
開發者ID:bfabiszewski,項目名稱:ulogger-android,代碼行數:28,代碼來源:MainActivity.java

示例6: build

import android.widget.Button; //導入依賴的package包/類
public EmptyView build(){
    if(parent == null)
        throw new IllegalArgumentException("No parent viewGroup");

    emptyView.view = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.empty_view, parent, false);
    TextView textView = ButterKnife.findById(emptyView.view, R.id.text_empty_hint);
    textView.setText(emptyHint);
    Button button = ButterKnife.findById(emptyView.view, R.id.btn_empty_view);
    button.setText(buttonText);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(mOnClickListener != null)
                mOnClickListener.onClick(v);
        }
    });
    parent.addView(emptyView.view);
    return emptyView;
}
 
開發者ID:SirLYC,項目名稱:Android-Gank-Share,代碼行數:21,代碼來源:EmptyView.java

示例7: updateUI

import android.widget.Button; //導入依賴的package包/類
private void updateUI() {
    getActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
            final Button button = (Button) getView().findViewById(R.id.connectButton);
            if (!InstagramClient.instance().isAuthenticated()) {
                button.setText(getString(R.string.login));
                button.setOnClickListener(new LoginClickListener());
            } else {
                button.setText(getString(R.string.logout));
                button.setOnClickListener(new LogoutClickListener(button));
            }

        }
    });
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:17,代碼來源:InstagramPreferencesFragment.java

示例8: onCreate

import android.widget.Button; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.range_picker_activity);

    CalendarView calendarView = (CalendarView) findViewById(R.id.calendarView);

    Button getDateButton = (Button) findViewById(R.id.getDateButton);
    getDateButton.setOnClickListener(v -> {
        for (Calendar calendar : calendarView.getSelectedDates()) {
            System.out.println(calendar.getTime().toString());

            Toast.makeText(getApplicationContext(),
                    calendar.getTime().toString(),
                    Toast.LENGTH_SHORT).show();
        }
    });
}
 
開發者ID:Applandeo,項目名稱:Material-Calendar-View,代碼行數:19,代碼來源:RangePickerActivity.java

示例9: onCreateView

import android.widget.Button; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
	
    View v = inflater.inflate(R.layout.fragment_exit, container, false);
    
    mSharedPreferences = getActivity().getSharedPreferences(
      	      "org.greenstand.android", Context.MODE_PRIVATE);

    Button yesBtn = (Button) v.findViewById(R.id.fragment_exit_yes);
    yesBtn.setOnClickListener(ExitFragment.this);

    Button noBtn = (Button) v.findViewById(R.id.fragment_exit_no);
    noBtn.setOnClickListener(ExitFragment.this);
    
    return v;
}
 
開發者ID:Greenstand,項目名稱:treetracker-android,代碼行數:18,代碼來源:ExitFragment.java

示例10: setUp

import android.widget.Button; //導入依賴的package包/類
@Before
public void setUp() {
	MockitoAnnotations.initMocks(this);
	changePasswordActivity =
			Robolectric.setupActivity(TestChangePasswordActivity.class);
	passwordConfirmationWrapper = (TextInputLayout) changePasswordActivity
			.findViewById(R.id.new_password_confirm_wrapper);
	currentPassword = (EditText) changePasswordActivity
			.findViewById(R.id.current_password_entry);
	newPassword = (EditText) changePasswordActivity
			.findViewById(R.id.new_password_entry);
	newPasswordConfirmation = (EditText) changePasswordActivity
			.findViewById(R.id.new_password_confirm);
	strengthMeter = (StrengthMeter) changePasswordActivity
			.findViewById(R.id.strength_meter);
	changePasswordButton = (Button) changePasswordActivity
			.findViewById(R.id.change_password);
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:19,代碼來源:ChangePasswordActivityTest.java

示例11: initDeleteButton

import android.widget.Button; //導入依賴的package包/類
protected void initDeleteButton(Button button, final Post post) {
    if (post.own) {
        button.setVisibility(0);
        button.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (AccountUtils.isVisitorAccount(BaseTimelineAdapter.this.activity)) {
                    CheckAccountPopwindow.showVisitorPopWindow(BaseTimelineAdapter.this
                            .activity);
                } else {
                    BaseTimelineAdapter.this.showDeleteDialog(post);
                }
            }
        });
        return;
    }
    button.setVisibility(8);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:18,代碼來源:BaseTimelineAdapter.java

示例12: onCreate

import android.widget.Button; //導入依賴的package包/類
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    setContentView(R.layout.confirm_delete);
    getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.WRAP_CONTENT);
    activity = this;
    mPrompt = (TextView) findViewById(R.id.prompt);
    mButton = (Button) findViewById(R.id.delete);
    mButton.setOnClickListener(mButtonClicked);

    (findViewById(R.id.cancel)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            finish();
        }
    });

    mPrompt.setText(getString(R.string.clear_online_dialog));
}
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:22,代碼來源:OnlineSearchClearHistory.java

示例13: displayYoutubeIdDialog

import android.widget.Button; //導入依賴的package包/類
private void displayYoutubeIdDialog(@NonNull ArrayList<YoutubeVideoData> youtubeVideoDataList) {
    final Dialog dialog = new Dialog(_context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_listview);

    TextView title = dialog.findViewById(R.id.dialog_title_text_view);
    title.setText(_context.getResources().getString(R.string.select_youtube_video));

    final YoutubeVideoListAdapter listAdapter = new YoutubeVideoListAdapter(_context, youtubeVideoDataList, dialog::dismiss);
    ListView listView = dialog.findViewById(R.id.dialog_list_view);
    listView.setAdapter(listAdapter);
    listView.setVisibility(View.VISIBLE);

    Button closeButton = dialog.findViewById(R.id.dialog_button_close);
    closeButton.setOnClickListener(view -> dialog.dismiss());

    dialog.setCancelable(true);
    dialog.show();

    Window window = dialog.getWindow();
    if (window != null) {
        window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
    } else {
        Logger.getInstance().Warning(TAG, "Window is null!");
    }
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-AndroidApplication,代碼行數:27,代碼來源:DownloadYoutubeVideoTask.java

示例14: ViewHolder

import android.widget.Button; //導入依賴的package包/類
public ViewHolder(final View itemView) {
    super(itemView);

    followRequestee = (TextView) itemView.findViewById(R.id.followRequesteeName);
    approveButton = (Button) itemView.findViewById(R.id.approveButton);
    declineButton = (Button) itemView.findViewById(R.id.declineButton);

    // listens when an item is clicked
    itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (listener != null) {
                int position = getAdapterPosition();
                if (position != RecyclerView.NO_POSITION) {
                    listener.onItemClick(itemView, position);
                }
            }
        }
    });
}
 
開發者ID:CMPUT301F17T15,項目名稱:CIA,代碼行數:21,代碼來源:FollowersRequestAdapter.java

示例15: initViews

import android.widget.Button; //導入依賴的package包/類
private void initViews() {
    latitudeInput = (EditText) findViewById(R.id.latitude_input);
    longitudeInput = (EditText) findViewById(R.id.longitude_input);
    mockLocationView = (TextView) findViewById(R.id.mock_location_view);
    updatedLocationView = (TextView) findViewById(R.id.updated_location_view);
    mockModeToggleButton = (ToggleButton) findViewById(R.id.toggle_button);
    setLocationButton = (Button) findViewById(R.id.set_location_button);

    mockModeToggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            setMockMode(isChecked);
            setLocationButton.setEnabled(isChecked);
        }
    });
    setLocationButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            addMockLocation();
        }
    });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:MockLocationsActivity.java


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