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


Java Button.setEnabled方法代碼示例

本文整理匯總了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);
	}
}
 
開發者ID:SShineTeam,項目名稱:Huochexing12306,代碼行數:37,代碼來源:ReminderSetupAty.java

示例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);
}
 
開發者ID:jiangchunyu,項目名稱:IPCCommunication,代碼行數:17,代碼來源:MainActivity.java

示例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();
}
 
開發者ID:SKT-ThingPlug,項目名稱:thingplug-sdk-android,代碼行數:17,代碼來源:SensorListActivity.java

示例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);
}
 
開發者ID:Liza-S,項目名稱:IT-Security-Quiz-App,代碼行數:28,代碼來源:MainActivity.java

示例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);

}
 
開發者ID:Francescopaolo44,項目名稱:AndroidApp-Deploy,代碼行數:16,代碼來源:Test.java

示例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;
}
 
開發者ID:serhataras,項目名稱:Roomie,代碼行數:37,代碼來源:CafeActivity.java

示例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();
}
 
開發者ID:Pingsh,項目名稱:Mix,代碼行數:13,代碼來源:DaggerMainActivity.java

示例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();
}
 
開發者ID:SShineTeam,項目名稱:Huochexing12306,代碼行數:30,代碼來源:EmailNextActivity.java

示例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;
        }
    });
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-android,代碼行數:35,代碼來源:LoginActivity.java

示例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);
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:9,代碼來源:MyDownloadingFragment.java

示例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);
}
 
開發者ID:Pablito2020,項目名稱:Recovery_Changer_Krillin,代碼行數:11,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:R-a-dio,項目名稱:R-a-dio-Amazing-Android-App,代碼行數:31,代碼來源:SongAdapter.java

示例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?
    }
}
 
開發者ID:Anuken,項目名稱:Mindustry,代碼行數:18,代碼來源:DonationsActivity.java

示例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);
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-android,代碼行數:33,代碼來源:HarvestFragment.java

示例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);
    }
}
 
開發者ID:Gericop,項目名稱:DateTimePicker,代碼行數:8,代碼來源:DatePickerDialog.java


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