Java Code Examples for android.widget.Button#setClickable()

The following examples show how to use android.widget.Button#setClickable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandupTimer.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
protected synchronized void disableIndividualTimer() {
    Logger.d("Disabling the individual timer");

    remainingIndividualSeconds = 0;

    TextView participantNumber = (TextView) findViewById(R.id.participant_number);
    participantNumber.setText("individual_status_complete");

    TextView individualTimeRemaining = (TextView) findViewById(R.id.individual_time_remaining);
    individualTimeRemaining.setText(TimeFormatHelper.formatTime(remainingIndividualSeconds));
    individualTimeRemaining.setTextColor(Color.GRAY);

    Button nextButton = (Button) findViewById(R.id.next_button);
    nextButton.setClickable(false);
    nextButton.setTextColor(Color.GRAY);
}
 
Example 2
Source File: MainActivity.java    From privacy-friendly-dame with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();
    currentGame = loadFile();
    Button game_continue = findViewById(R.id.continueButton);
    if (currentGame == null || currentGame.isGameFinished())
    {
        // no saved game available
        game_continuable = false;
        game_continue.setClickable(true);
        game_continue.setBackgroundResource(R.drawable.button_disabled);
    }
    else
    {
        game_continuable = true;
        game_continue.setClickable(true);
        game_continue.setBackgroundResource(R.drawable.standalone_button);
    }
}
 
Example 3
Source File: PaneledChoiceDialog.java    From commcare-android with Apache License 2.0 6 votes vote down vote up
public static void populateChoicePanel(Context context, Button choicePanel,
                                       DialogChoiceItem item, boolean iconToLeft) {
    choicePanel.setText(item.text);
    if (item.listener != null) {
        choicePanel.setOnClickListener(item.listener);
    } else {
        // needed to propagate clicks down to the ListView's ItemClickListener
        choicePanel.setFocusable(false);
        choicePanel.setClickable(false);
    }
    if (item.iconResId != -1) {
        Drawable icon = ContextCompat.getDrawable(context, item.iconResId);
        if (iconToLeft) {
            if (LocalePreferences.isLocaleRTL())
                choicePanel.setCompoundDrawablesWithIntrinsicBounds(null, null, icon, null);
            else
                choicePanel.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
        } else {
            choicePanel.setCompoundDrawablesWithIntrinsicBounds(null, icon, null, null);
        }
    }
}
 
Example 4
Source File: GoJsActivity.java    From DragonGoApp with GNU Affero General Public License v3.0 6 votes vote down vote up
void initFinished() {
	System.out.println("init finished");
	writeInLabel("init done. You can play !");
	final Button button1 = (Button)findViewById(R.id.but1);
	button1.setClickable(true);
	button1.setEnabled(true);
	final Button button2 = (Button)findViewById(R.id.but2);
	button2.setClickable(true);
	button2.setEnabled(true);
	final Button button3 = (Button)findViewById(R.id.but3);
	button3.setClickable(true);
	button3.setEnabled(true);
	button1.invalidate();
	button2.invalidate();
	button3.invalidate();
}
 
Example 5
Source File: StandupTimer.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
protected synchronized void disableIndividualTimer() {
    Logger.d("Disabling the individual timer");

    remainingIndividualSeconds = 0;

    TextView participantNumber = (TextView) findViewById(R.id.participant_number);
    participantNumber.setText("individual_status_complete");

    TextView individualTimeRemaining = (TextView) findViewById(R.id.individual_time_remaining);
    individualTimeRemaining.setText(TimeFormatHelper.formatTime(remainingIndividualSeconds));
    individualTimeRemaining.setTextColor(Color.GRAY);

    Button nextButton = (Button) findViewById(R.id.next_button);
    nextButton.setClickable(false);
    nextButton.setTextColor(Color.GRAY);
}
 
Example 6
Source File: EliminateMainActivity.java    From android-tv-launcher with MIT License 6 votes vote down vote up
public void Init() {
GetSurplusMemory();
Round_img=(ImageView)findViewById(R.id.eliminate_roundimg);
Start_kill=(Button)findViewById(R.id.start_killtask);
release_memory=(TextView)findViewById(R.id.relase_memory);
increase_speed=(TextView)findViewById(R.id.increase_speed);
Allpercent=(TextView)findViewById(R.id.all_percent);
clear_endlayout=(LinearLayout)findViewById(R.id.clear_endlayout);
Clearing_layout=(RelativeLayout)findViewById(R.id.clearing_layout);
Animation animation=AnimationUtils.loadAnimation(EliminateMainActivity.this, R.anim.eliminatedialog_anmiation);
TotalMemory=GetTotalMemory();
Round_img.setAnimation(animation);
Start_kill.setClickable(false);
Start_kill.setOnClickListener(new OnClickListener() {
	
	@Override
	public void onClick(View arg0) {
		// TODO Auto-generated method stub
	finish();	
	}
});
}
 
Example 7
Source File: MainActivity.java    From privacy-friendly-ludo with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onRestart() {
    super.onRestart();
    model = loadFile();
    Button game_continue = (Button) findViewById(R.id.game_button_continue);
    if (model == null || model.isGame_finished())
    {
        // no saved game available
        game_continuable = false;
        game_continue.setClickable(true);
        game_continue.setBackgroundColor(ContextCompat.getColor(getBaseContext(),(R.color.middlegrey)));
    }
    else
    {
        game_continuable = true;
        game_continue.setClickable(true);
        game_continue.setBackgroundColor(ContextCompat.getColor(getBaseContext(),R.color.colorPrimary));
    }
}
 
Example 8
Source File: MainActivity.java    From Adafruit_Android_BLE_UART with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Grab references to UI elements.
    messages = (TextView) findViewById(R.id.messages);
    input = (EditText) findViewById(R.id.input);

    // Initialize UART.
    uart = new BluetoothLeUart(getApplicationContext());

    // Disable the send button until we're connected.
    send = (Button)findViewById(R.id.send);
    send.setClickable(false);
    send.setEnabled(false);

    // Enable auto-scroll in the TextView
    messages.setMovementMethod(new ScrollingMovementMethod());
}
 
Example 9
Source File: ProgressDialogLayout.java    From weMessage with GNU Affero General Public License v3.0 5 votes vote down vote up
public void showButton(){
    Button actionButton = findViewById(R.id.progressDialogButton);
    LinearLayout buttonContainer = findViewById(R.id.progressDialogButtonContainer);

    actionButton.setClickable(true);
    actionButton.setVisibility(View.VISIBLE);
    buttonContainer.setVisibility(View.VISIBLE);
}
 
Example 10
Source File: RegisterActivity.java    From sealtalk-android with MIT License 5 votes vote down vote up
private void initView() {
    mPhoneEdit = (ClearWriteEditText) findViewById(R.id.reg_phone);
    mCodeEdit = (ClearWriteEditText) findViewById(R.id.reg_code);
    mNickEdit = (ClearWriteEditText) findViewById(R.id.reg_username);
    mPasswordEdit = (ClearWriteEditText) findViewById(R.id.reg_password);
    mGetCode = (Button) findViewById(R.id.reg_getcode);
    mConfirm = (Button) findViewById(R.id.reg_button);

    mGetCode.setOnClickListener(this);
    mGetCode.setClickable(false);
    mConfirm.setOnClickListener(this);

    goLogin = (TextView) findViewById(R.id.reg_login);
    goForget = (TextView) findViewById(R.id.reg_forget);
    goLogin.setOnClickListener(this);
    goForget.setOnClickListener(this);

    mImgBackgroud = (ImageView) findViewById(R.id.rg_img_backgroud);
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            Animation animation = AnimationUtils.loadAnimation(RegisterActivity.this, R.anim.translate_anim);
            mImgBackgroud.startAnimation(animation);
        }
    }, 200);

    addEditTextListener();

}
 
Example 11
Source File: AsyncTaskExtend.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPostExecute(Object result) {

    ZogUtils.printLog(AsyncTaskExtend.class, "onPostExecute");

    for (Button b : btns) {
        b.setClickable(true);
    }
    for (LinearLayout ll : linearLayouts) {
        ll.setClickable(true);
    }
}
 
Example 12
Source File: ZenMenuAdapter.java    From zen4android with MIT License 5 votes vote down vote up
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
		View convertView, ViewGroup parent) {
	Map<String, String> map = (Map<String, String>)mHeaders.get(groupPosition);
	String text = (String)map.get("name");
	if(convertView == null) {
		convertView = mInflater.inflate(R.layout.zen_menu_group, null);			
	}
	ImageButton itemLeft = (ImageButton)convertView.findViewById(R.id.zen_menu_header_left);
	Button itemRight = (Button)convertView.findViewById(R.id.zen_menu_header_right);
	itemRight.setText(text);
	
	itemLeft.setImageResource(R.drawable.menu_right_arrow);
	if(isExpanded) {
		itemLeft.setImageResource(R.drawable.menu_down_arrow);
	}
	
	int background = menu_item_backgrounds[groupPosition%9];
	itemLeft.setBackgroundResource(background);
	itemRight.setBackgroundResource(background);
	itemLeft.setFocusable(false);
	itemRight.setFocusable(false);
	itemLeft.setClickable(false);
	itemRight.setClickable(false);
	
	
	
	return convertView;
}
 
Example 13
Source File: NewListDialog.java    From DMusic with Apache License 2.0 5 votes vote down vote up
@Override
protected void init(View rootView) {
    etName = (EditText) rootView.findViewById(R.id.et_name);
    btnOk = (Button) rootView.findViewById(R.id.btn_ok);
    btnCancel = (Button) rootView.findViewById(R.id.btn_cancel);
    btnOk.setClickable(false);
    btnOk.setOnClickListener(this);
    btnCancel.setOnClickListener(this);
    etName.addTextChangedListener(this);
}
 
Example 14
Source File: VhostsActivity.java    From Virtual-Hosts with GNU General Public License v3.0 5 votes vote down vote up
private void setButton(boolean enable) {
    final SwitchButton vpnButton = (SwitchButton) findViewById(R.id.button_start_vpn);
    final Button selectHosts = (Button) findViewById(R.id.button_select_hosts);
    if (enable) {
        vpnButton.setChecked(false);
        selectHosts.setAlpha(1.0f);
        selectHosts.setClickable(true);
    } else {
        vpnButton.setChecked(true);
        selectHosts.setAlpha(.5f);
        selectHosts.setClickable(false);
    }
}
 
Example 15
Source File: MyDownloadingFragment.java    From letv with Apache License 2.0 5 votes vote down vote up
private void setButtonStatus(Button button, boolean canClick) {
    Logger.d(TAG, " setButtonStatus canClick : " + canClick);
    if (canClick) {
        button.setClickable(true);
        button.setBackgroundResource(R.drawable.btn_blue_selecter);
        button.setTextAppearance(this.mContext, R.style.letv_text_13_blue_white);
        return;
    }
    button.setClickable(false);
    button.setBackgroundResource(R.drawable.btn_grey);
    button.setTextColor(Util.getContext().getResources().getColor(R.color.letv_color_ffa1a1a1));
}
 
Example 16
Source File: VerifyActivity.java    From sealrtc-android with MIT License 5 votes vote down vote up
private void initView() {
    btn_login = (Button) findViewById(R.id.btn_login);
    reg_getcode = (Button) findViewById(R.id.reg_getcode);
    btn_login.setOnClickListener(onClickListener);
    btn_login.setClickable(false);

    reg_getcode.setOnClickListener(onClickListener);
    edit_phone = (EditText) findViewById(R.id.edit_phone);
    String phone = SessionManager.getInstance().getString(UserUtils.PHONE);
    if (!TextUtils.isEmpty(phone)) {
        edit_phone.setText(phone);
        reg_getcode.setClickable(true);
        reg_getcode.setBackgroundDrawable(
            getResources().getDrawable(R.drawable.rs_select_btn_blue));
    }
    tv_tips = (TextView) findViewById(R.id.tv_tips);
    edit_verificationCode = (EditText) findViewById(R.id.edit_verificationCode);
    versionCodeView = (TextView) findViewById(R.id.main_page_version_code);
    versionCodeView.setText(
        getResources().getString(R.string.blink_description_version)
            + BuildConfig.VERSION_NAME
            + (BuildConfig.DEBUG ? "_Debug" : ""));
    versionCodeView.setTextColor(getResources().getColor(R.color.blink_text_green));
    mTvRegion = (TextView) findViewById(R.id.tv_region);
    mTvCountry = (TextView) findViewById(R.id.tv_country);
    mTvCountry.setOnClickListener(onClickListener);
    updateCountry();
    img_logo = (ImageView) findViewById(R.id.img_logo);
    if (img_logo != null) {
        if (ServerUtils.usePrivateCloud()) {
            img_logo.setImageResource(R.drawable.ic_launcher_privatecloud);
        } else {
            img_logo.setImageResource(R.drawable.ic_launcher);
        }
    }
}
 
Example 17
Source File: CircularButton.java    From green_android with GNU General Public License v3.0 4 votes vote down vote up
public CircularButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CircularButton);

    setLayoutTransition(new LayoutTransition());

    setRadius(getPx(DEFAULT_RADIUS));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setElevation(getPx(DEFAULT_ELEVATION));
    }

    mLinearLayout = new LinearLayout(context);
    mLinearLayout.setOrientation(LinearLayout.VERTICAL);

    // set selectable background
    final TypedValue typedValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
                                             typedValue, true);
    mSelectableItemBackground = typedValue.resourceId;
    mLinearLayout.setBackgroundResource(mSelectableItemBackground);

    // create button
    mButton = new Button(context);
    mButton.setBackgroundColor(Color.TRANSPARENT);
    mButton.setClickable(false);
    mButton.setPadding((int)getPx(15), mButton.getPaddingTop(), (int)getPx(15),
                       mButton.getPaddingBottom());
    final String text = typedArray.getString(R.styleable.CircularButton_text);
    mButton.setText(text);
    mButton.setTextColor(typedArray.getColor(R.styleable.CircularButton_textColor, Color.BLACK));

    // create progressbar
    mProgressBar = new ProgressBar(context);
    mProgressBar.setVisibility(View.GONE);

    // animation transaction
    final LayoutTransition layoutTransition = getLayoutTransition();
    layoutTransition.setDuration(DEFAULT_DURATION);
    layoutTransition.enableTransitionType(LayoutTransition.CHANGING);

    this.setOnClickListener(view -> {
        if (isClickable()) {
            startLoading();
        }
    });

    // set background color animations
    mBackgroundColor = typedArray.getColorStateList(R.styleable.CardView_cardBackgroundColor)
                       .getDefaultColor();
    final ColorDrawable[] color1 = {new ColorDrawable(mBackgroundColor),
                                    new ColorDrawable(Color.WHITE)};
    mTransStartLoading = new TransitionDrawable(color1);
    final ColorDrawable[] color2 = {new ColorDrawable(mSelectableItemBackground), new
                                    ColorDrawable(mBackgroundColor)};
    mTransStopLoading = new TransitionDrawable(color2);

    // set progressbar for API < lollipop
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        mProgressBar.setBackgroundColor(Color.WHITE);
        mProgressBar.getIndeterminateDrawable().setColorFilter(
            mBackgroundColor, PorterDuff.Mode.SRC_IN);
    }

    typedArray.recycle();

    // get the width set
    final int[] width = new int[] { android.R.attr.layout_width };
    final TypedArray typedArray1 = context.obtainStyledAttributes(attrs, width);
    mLayoutWidth = typedArray1.getLayoutDimension(0, ViewGroup.LayoutParams.WRAP_CONTENT);
    typedArray1.recycle();

    mLinearLayout.addView(mButton);
    mLinearLayout.addView(mProgressBar);
    addView(mLinearLayout);
}
 
Example 18
Source File: OrderDetailFragment.java    From Pharmacy-Android with GNU General Public License v3.0 4 votes vote down vote up
private void disableButton(Button button) {
    button.setClickable(false);
    button.setAlpha(0.5f);
}
 
Example 19
Source File: LoginActivity.java    From Mobike with Apache License 2.0 2 votes vote down vote up
/**
 * 改变bt颜色red设置可点击
 *
 * @param bt
 */
private void setButtonRed(Button bt) {
    bt.setClickable(true);
    bt.setBackgroundResource(R.color.red);
}
 
Example 20
Source File: LoginActivity.java    From Mobike with Apache License 2.0 2 votes vote down vote up
/**
 * 改变bt颜色gray设置不可点击
 *
 * @param bt
 */
private void setButtonGray(Button bt) {
    bt.setClickable(false);
    bt.setBackgroundResource(R.color.gray);
}