本文整理汇总了Java中android.widget.Button.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setEnabled方法的具体用法?Java Button.setEnabled怎么用?Java Button.setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.Button
的用法示例。
在下文中一共展示了Button.setEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initViews
import android.widget.Button; //导入方法依赖的package包/类
private void initViews() {
//提醒设置
ivStart = (ImageView)findViewById(R.id.from);
ivStart.setOnClickListener(this);
ivEnd = (ImageView)findViewById(R.id.to);
ivEnd.setOnClickListener(this);
btnPreReminderTime = (Button)findViewById(R.id.time);
btnPreReminderTime.setOnClickListener(this);
ivRing = (ImageView)findViewById(R.id.ring);
ivRing.setOnClickListener(this);
ivVibrate = (ImageView)findViewById(R.id.vibrate);
ivVibrate.setOnClickListener(this);
tvMIUIRepair = (TextView)findViewById(R.id.repair);
tvMIUIRepair.setOnClickListener(this);
Button btnReminderDemo = (Button)findViewById(R.id.demo);
btnReminderDemo.setOnClickListener(this);
btnPreReminderTime.setText(setSP.getPreReminderTimeString());
ivVibrate.setImageResource(setSP.isVibrate()==true ? R.drawable.chat_on:R.drawable.chat_off);
ivRing.setImageResource(setSP.isRing()==true ? R.drawable.chat_on:R.drawable.chat_off);
ivStart.setImageResource(setSP.isStartReminder()==true ? R.drawable.chat_on:R.drawable.chat_off);
ivEnd.setImageResource(setSP.isEndReminder()==true ? R.drawable.chat_on:R.drawable.chat_off);
if (!setSP.isReminderSet()){
btnPreReminderTime.setEnabled(false);
ivRing.setEnabled(false);
ivVibrate.setEnabled(false);
tvMIUIRepair.setEnabled(false);
}else{
btnPreReminderTime.setEnabled(true);
ivRing.setEnabled(true);
ivVibrate.setEnabled(true);
tvMIUIRepair.setEnabled(true);
}
}
示例2: onCreate
import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTextView = (TextView) findViewById(R.id.tv_service);
tv_state = (TextView) findViewById(R.id.tv_state);
btnGet = (Button) findViewById(R.id.btn_getService);
btn_bind = (Button) findViewById(R.id.btn_bind);
btn_unbind = (Button) findViewById(R.id.btn_unbind);
btnGet.setEnabled(false);
tv_state.setText(" 服务未绑定 ");
mClientUtils = new ClientUtils(this);
mClientUtils.setConnectListener(mConnectListener);
btn_bind.setEnabled(true);
btn_unbind.setEnabled(false);
}
示例3: resultControlDevice
import android.widget.Button; //导入方法依赖的package包/类
private void resultControlDevice(boolean isSuccess, int resString, SensorInfo sensorInfo, Button button) {
if(button != null) {
button.setEnabled(true);
} else {
sensorInfo.setSuspend(false);
}
if (!isSuccess) {
if (sensorInfo.getType().getCategory() != SensorType.Category.ACTUATOR) {
sensorInfo.setActivated(!sensorInfo.isActivated());
}
sensorInfo.setSuspend(false);
}
String toastMessage = String.format(getResources().getString(resString), sensorInfo.getType().getNickname());
Toast.makeText(this, toastMessage, Toast.LENGTH_SHORT).show();
}
示例4: end_Test
import android.widget.Button; //导入方法依赖的package包/类
/**
* This method is called when the end test button is clicked.
*/
public void end_Test(View view) {
EditText nameField = (EditText) findViewById(R.id.name_field);
String name = nameField.getText().toString();
//Called question checking methods
question_1();
question_2();
question_3();
question_4();
question_5();
question_6();
question_7();
question_8();
question_9();
question_10();
// Display the test result on the screen
String test_result = createTestResult(name, score);
displayResult(test_result);
// Disabled "End Test" button after clicking on it.
Button endTestButton = (Button) findViewById(R.id.end_test_button);
endTestButton.setEnabled(false);
}
示例5: onCreate
import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
//widget
crono = (Chronometer) findViewById(R.id.crono);
Start = (Button) findViewById(R.id.start);
Stop = (Button) findViewById(R.id.stop);
Start.setEnabled(true);
Stop.setEnabled(false);
}
示例6: getView
import android.widget.Button; //导入方法依赖的package包/类
@Override
public View getView(final int position, View convertView, final ViewGroup parent)
{
// inflate the layout for each list row
convertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.cafe_food_item, parent, false);
// get current item to be displayed
final FoodItem currentItem = (FoodItem) getItem(position);
// get the TextView for item name and item description
TextView itemText = (TextView) convertView.findViewById(R.id.list_item_text);
itemText.setText(currentItem.getName());
TextView priceText = (TextView) convertView.findViewById(R.id.foodPrice);
priceText.setText("Price: " + currentItem.getPrice());
Button useButton = (Button) convertView.findViewById(R.id.list_item_btn);
useButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
((Cafe)game.getGameEnvironment().getOutdoorEnvironment(OptionType.CAFE_OPTION)).setSelectedFood((FoodItem)getItem(position));
finish();
}
});
// deactivate button if the player has not enough money
if (game.getPlayer().getStats().getStatByIndex(StatType.MONEY) < currentItem.getPrice())
{
useButton.setEnabled(false);
useButton.setAlpha(0.3f);
itemText.setText(currentItem.getName() + " (Not enough money!)");
}
// returns the view for the current row
return convertView;
}
示例7: initView
import android.widget.Button; //导入方法依赖的package包/类
private void initView() {
mRelativeLayout = (RelativeLayout) findViewById(R.id.rl_content);
mSuccessLayout = (RelativeLayout) findViewById(R.id.rl_success);
etDate = (EditText) findViewById(R.id.et_date);
btnSearch = (Button) findViewById(R.id.search_dagger);
btnSearch.setEnabled(false);
tvLunar = (TextView) findViewById(R.id.tv_lunar);
initListener();
}
示例8: initViews
import android.widget.Button; //导入方法依赖的package包/类
private void initViews() {
strReSend = this.getIntent().getStringExtra(RESEND_STR);
strVerifyNum = this.getIntent().getStringExtra(VERIFY_NUM);
strTempAuthCode = this.getIntent().getStringExtra(AUTH_CODE);
strOperate = this.getIntent().getStringExtra(OPERATE);
tvVerifyNum = (TextView) findViewById(R.id.verifyNum);
etAuthCode = (EditText)findViewById(R.id.code);
Button btnOK = (Button)findViewById(R.id.ok);
btnOK.setOnClickListener(this);
btnReSendKey = (Button)findViewById(R.id.resend);
btnReSendKey.setOnClickListener(this);
tvVerifyNum.setText(strVerifyNum);
btnReSendKey.setEnabled(false);
CountDownTimer cdTimer = new CountDownTimer(60000, 1000){
@Override
public void onFinish() {
btnReSendKey.setEnabled(true);
btnReSendKey.setText("重新发送验证码");
}
@Override
public void onTick(long millisUntilFinished) {
btnReSendKey.setText("重新发送(" + millisUntilFinished/1000 + "秒)");
}
};
cdTimer.start();
}
示例9: setupButtons
import android.widget.Button; //导入方法依赖的package包/类
void setupButtons(boolean restarted) {
mLoginButton = (Button) findViewById(R.id.loginbutton);
if (Utils.checkPlayServices(this)) {
// Login automatically if credentials are stored
if (GameDatabase.getInstance().credentialsStored(this)) {
if (restarted) {
finish();
return;
}
GameDatabase.getInstance().loginWithStoredCredentials(getWorkContext(), false);
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
replaceWithMainActivity(intent);
return;
}
mLoginButton.setEnabled(true);
mLoginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText usernameField = (EditText) findViewById(R.id.username);
EditText passwordField = (EditText) findViewById(R.id.password);
attemptLogin(usernameField.getText().toString(), passwordField.getText().toString());
}
});
}
findViewById(R.id.layout).setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent ev) {
Utils.hideKeyboard(LoginActivity.this, view);
return false;
}
});
}
示例10: setButtonStatus
import android.widget.Button; //导入方法依赖的package包/类
private void setButtonStatus(Button button, boolean canClick) {
LogInfo.log(TAG, " setButtonStatus canClick : " + canClick);
if (canClick) {
button.setEnabled(true);
} else {
button.setEnabled(false);
}
}
示例11: disableButtons
import android.widget.Button; //导入方法依赖的package包/类
private void disableButtons(){
Button btn1 = (Button) findViewById(R.id.button);
btn1.setEnabled(false);
Button btn2 = (Button) findViewById(R.id.button2);
btn2.setEnabled(false);
Button btn3 = (Button) findViewById(R.id.button3);
btn3.setEnabled(false);
Button btn4 = (Button) findViewById(R.id.button4);
btn4.setEnabled(false);
}
示例12: getView
import android.widget.Button; //导入方法依赖的package包/类
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if(view == null){
LayoutInflater inflater = LayoutInflater.from(mContext);
view = inflater.inflate(R.layout.request_cell, null);
}
Song song = mSongs.get(position);
TextView titleView = (TextView) view.findViewById(R.id.songTitle);
TextView artistView = (TextView) view.findViewById(R.id.artistName);
Button requestButton = (Button) view.findViewById(R.id.requestButton);
titleView.setText(song.getSongTitle());
artistView.setText(song.getArtistName());
requestButton.setEnabled(song.IsRequestable());
requestButton.setHint(song.getSongID().toString());
requestButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Button b = (Button) v;
mActivity.makeRequest(Integer.parseInt(b.getHint().toString()));
}
});
return view;
}
示例13: onActivityResult
import android.widget.Button; //导入方法依赖的package包/类
/**
* Needed for Google Play In-app Billing. It uses startIntentSenderForResult(). The result is not propagated to
* the Fragment like in startActivityForResult(). Thus we need to propagate manually to our Fragment.
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Button b = ((Button)findViewById(org.sufficientlysecure.donations.R.id.donations__google_android_market_donate_button));
b.setEnabled(true);
FragmentManager fragmentManager = getSupportFragmentManager();
Fragment fragment = fragmentManager.findFragmentByTag("donationsFragment");
if (fragment != null) {
fragment.onActivityResult(requestCode, resultCode, data);
//TODO donation event, set settings?
}
}
示例14: setEditModeEnabled
import android.widget.Button; //导入方法依赖的package包/类
void setEditModeEnabled(boolean enabled) {
mEditModeEnabled = enabled;
mButtonView.setVisibility(enabled ? View.VISIBLE : View.GONE);
mSubmitButton.setVisibility(enabled ? View.VISIBLE : View.GONE);
mDismissButton.setVisibility(enabled ? View.VISIBLE : View.GONE);
mDescriptionEdit.setEnabled(enabled);
mDescriptionEdit.setHint(enabled ? getString(R.string.add_description) : null);
refreshMooseInputState(enabled);
refreshAmountInputState(enabled);
refreshEditToolsState();
Button speciesButton = mSelectSpeciesButton.getSpeciesButton();
if (mEvent != null) {
if (mEvent.isEditable()) {
speciesButton.setEnabled(enabled);
mSpecimenDetails.setEnabled(enabled);
mPermitCheckbox.setEnabled(enabled);
mPermitNumber.setEnabled(enabled);
} else {
speciesButton.setEnabled(false);
mSpecimenDetails.setEnabled(false);
mPermitCheckbox.setEnabled(false);
mPermitNumber.setEnabled(false);
}
}
speciesButton.setVisibility(enabled && TextUtils.isEmpty(mEvent.mPermitNumber) ? View.VISIBLE : View.GONE);
mPermitCheckbox.setVisibility(enabled || !TextUtils.isEmpty(mEvent.mPermitNumber) ? View.VISIBLE : View.GONE);
mPermitNumber.setVisibility(enabled && !TextUtils.isEmpty(mEvent.mPermitNumber) ? View.VISIBLE : View.GONE);
mDiaryImageManager.setEditMode(enabled);
}
示例15: onValidationChanged
import android.widget.Button; //导入方法依赖的package包/类
@Override
public void onValidationChanged(boolean valid) {
final Button positive = getButton(BUTTON_POSITIVE);
if (positive != null) {
positive.setEnabled(valid);
}
}