Java Code Examples for android.widget.TextView.setEnabled()

The following are Jave code examples for showing how to use setEnabled() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: decoy   File: NormalTeamInfoActivity.java   View Source Code Vote up 7 votes
private void updateTeamInfo(Team t) {
    if (t == null) {
        return;
    }

    team = t;

    // title
    String teamName = team.getName();
    setTitle(teamName);

    // team name
    View nameView = findViewById(R.id.settings_item_name);
    teamNameTextView = (TextView) nameView.findViewById(R.id.item_detail);
    teamNameTextView.setText(teamName);
    teamNameTextView.setEnabled(isSelfAdmin);

    setToggleBtn(team);
}
 
Example 2
Project: yyox   File: FeedBackActivity.java   View Source Code Vote up 6 votes
@Override
protected void initWidgets() {
    super.initWidgets();
    mImgContainerLayout = (LinearLayout) findViewById(R.id.kf5_feed_back_image_layout);
    mETContent = (EditText) findViewById(R.id.kf5_feed_back_content_et);
    mETContent.setOnTouchListener(this);
    mETContent.addTextChangedListener(new ETTextWatcher());
    mImgChoiceImg = (ImageView) findViewById(R.id.kf5_feed_back_choice_img);
    mImgChoiceImg.setOnClickListener(this);
    mParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    mParams.bottomMargin = 1;
    mBackImg = (ImageView) findViewById(R.id.kf5_return_img);
    mBackImg.setOnClickListener(this);
    mTVSubmit = (TextView) findViewById(R.id.kf5_right_text_view);
    mTVSubmit.setOnClickListener(this);
    mTVSubmit.setEnabled(false);
}
 
Example 3
Project: zhbj74   File: LeftMenuFragment.java   View Source Code Vote up 6 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	View view = View.inflate(mActivity, R.layout.list_item_left_menu,null);
	TextView tvMenu = (TextView) view.findViewById(R.id.tv_menu);
	NewsMenuData item = getItem(position);
	tvMenu.setText(item.title);
	//����ѡ�в˵���ɫ
	if(position==mCurrentPos){
		//��ѡ��
		tvMenu.setEnabled(true);
	}else{
		tvMenu.setEnabled(false);
	}
	
	return view;
}
 
Example 4
Project: Huochexing12306   File: ReminderSetupAty.java   View Source Code Vote up 6 votes
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);
	}
}
 
Example 5
Project: CXJPadProject   File: QuoteProcessInnerItem.java   View Source Code Vote up 6 votes
@Override
public void bindViews(View view) {
    cbx_select = (CheckBox) view.findViewById(R.id.cbx_select);
    tv_name = (TextView) view.findViewById(R.id.tv_name);
    mCarrier = (TextView) view.findViewById(R.id.tv_carrier);
    mSkuType = (TextView) view.findViewById(R.id.tv_skuType);
    mSkuBrand = (TextView) view.findViewById(R.id.tv_skuBrand);
    mPurNum = (TextView) view.findViewById(R.id.tv_num);
    addView = (ImageView) view.findViewById(R.id.addView);
    subView = (ImageView) view.findViewById(R.id.subView);
    addView.setVisibility(tmpSelectModel.multi ? View.VISIBLE : View.GONE);
    subView.setVisibility(tmpSelectModel.multi ? View.VISIBLE : View.GONE);
    mPurNum.setEnabled(false);
    mUnit = (TextView) view.findViewById(R.id.tv_unit);
    mUnitPrice = (TextView) view.findViewById(R.id.tv_unitPrice);
    mArrivalTime = (TextView) view.findViewById(R.id.tv_arrivalTime);
    mPurRemark = (TextView) view.findViewById(R.id.tv_purRemark);
}
 
Example 6
Project: LiuAGeAndroid   File: OptionalGridViewAdapter.java   View Source Code Vote up 6 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view = LayoutInflater.from(context).inflate(R.layout.item_column_item, null);
    item_text = (TextView) view.findViewById(R.id.text_item);
    String className = getItem(position).getClassname();
    item_text.setText(className);
    if (isSelected) {
        if (position == 0) {
            item_text.setEnabled(false);
        }
    }
    if (!isVisible && (position == -1 + optionalList.size())) {
        item_text.setText("");
        item_text.setSelected(true);
        item_text.setEnabled(true);
    }
    if (remove_position == position) {
        item_text.setText("");
    }
    return view;
}
 
Example 7
Project: FireFiles   File: MoveFragment.java   View Source Code Vote up 6 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	//final Context context = inflater.getContext();

	final View view = inflater.inflate(R.layout.fragment_move, container, false);
	view.findViewById(R.id.background).setBackgroundColor(SettingsActivity.getPrimaryColor(getActivity()));

	mCancel = (ImageButton) view.findViewById(android.R.id.button2);
	mCancel.setOnClickListener(this);

	mMoveInfo = (TextView) view.findViewById(android.R.id.title);
	mMoveInfo.setText("Paste " + FileUtils.formatFileCount(docs.size()) + " in ");
	mMoveInfo.setEnabled(false);
	
	mRootInfo = (TextView) view.findViewById(android.R.id.text1);

	mSave = (ImageButton) view.findViewById(android.R.id.button1);
	mSave.setOnClickListener(this);
	mSave.setEnabled(false);

	mProgress = (MaterialProgressBar) view.findViewById(android.R.id.progress);
	mProgress.setColor(SettingsActivity.getAccentColor());

	return view;
}
 
Example 8
Project: boohee_v5.6   File: StatusBlockFragment.java   View Source Code Vote up 6 votes
private void setCheckInUI(int count, boolean isChecked) {
    boolean z;
    String message = String.format(getString(R.string.d7), new Object[]{Integer.valueOf
            (count)});
    SpannableString ss = new SpannableString(message);
    ss.setSpan(new ForegroundColorSpan(SupportMenu.CATEGORY_MASK), 5, message.length() - 1, 33);
    this.checkInMsgText.setText(ss);
    this.checkInBtn.setText(isChecked ? R.string.d4 : R.string.d6);
    TextView textView = this.checkInBtn;
    if (isChecked) {
        z = false;
    } else {
        z = true;
    }
    textView.setEnabled(z);
}
 
Example 9
Project: decoy   File: LoginActivity.java   View Source Code Vote up 5 votes
private void updateRightTopBtn(Context context, TextView rightTopBtn, boolean isEnable) {
    rightTopBtn.setText(R.string.done);
    rightTopBtn.setBackgroundResource(R.drawable.g_white_btn_selector);
    rightTopBtn.setEnabled(isEnable);
    rightTopBtn.setTextColor(context.getResources().getColor(R.color.color_blue_0888ff));
    rightTopBtn.setPadding(ScreenUtil.dip2px(10), 0, ScreenUtil.dip2px(10), 0);
}
 
Example 10
Project: AOSP-Kayboard-7.1.2   File: SuggestionStripLayoutHelper.java   View Source Code Vote up 5 votes
/**
 * Format appropriately the suggested word in {@link #mWordViews} specified by
 * <code>positionInStrip</code>. When the suggested word doesn't exist, the corresponding
 * {@link TextView} will be disabled and never respond to user interaction. The suggested word
 * may be shrunk or ellipsized to fit in the specified width.
 *
 * The <code>positionInStrip</code> argument is the index in the suggestion strip. The indices
 * increase towards the right for LTR scripts and the left for RTL scripts, starting with 0.
 * The position of the most important suggestion is in {@link #mCenterPositionInStrip}. This
 * usually doesn't match the index in <code>suggedtedWords</code> -- see
 * {@link #getPositionInSuggestionStrip(int,SuggestedWords)}.
 *
 * @param positionInStrip the position in the suggestion strip.
 * @param width the maximum width for layout in pixels.
 * @return the {@link TextView} containing the suggested word appropriately formatted.
 */
private TextView layoutWord(final Context context, final int positionInStrip, final int width) {
    final TextView wordView = mWordViews.get(positionInStrip);
    final CharSequence word = wordView.getText();
    if (positionInStrip == mCenterPositionInStrip && mMoreSuggestionsAvailable) {
        // TODO: This "more suggestions hint" should have a nicely designed icon.
        wordView.setCompoundDrawablesWithIntrinsicBounds(
                null, null, null, mMoreSuggestionsHint);
        // HACK: Align with other TextViews that have no compound drawables.
        wordView.setCompoundDrawablePadding(-mMoreSuggestionsHint.getIntrinsicHeight());
    } else {
        wordView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
    }
    // {@link StyleSpan} in a content description may cause an issue of TTS/TalkBack.
    // Use a simple {@link String} to avoid the issue.
    wordView.setContentDescription(
            TextUtils.isEmpty(word)
                ? context.getResources().getString(R.string.spoken_empty_suggestion)
                : word.toString());
    final CharSequence text = getEllipsizedTextWithSettingScaleX(
            word, width, wordView.getPaint());
    final float scaleX = wordView.getTextScaleX();
    wordView.setText(text); // TextView.setText() resets text scale x to 1.0.
    wordView.setTextScaleX(scaleX);
    // A <code>wordView</code> should be disabled when <code>word</code> is empty in order to
    // make it unclickable.
    // With accessibility touch exploration on, <code>wordView</code> should be enabled even
    // when it is empty to avoid announcing as "disabled".
    wordView.setEnabled(!TextUtils.isEmpty(word)
            || AccessibilityUtils.getInstance().isTouchExplorationEnabled());
    return wordView;
}
 
Example 11
Project: LiuAGeAndroid   File: DragGridViewAdapter.java   View Source Code Vote up 5 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view = LayoutInflater.from(context).inflate(R.layout.item_column_item, null);
    item_text = (TextView) view.findViewById(R.id.text_item);
    String className = getItem(position).getClassname();
    item_text.setText(className);
    if (isUser) {
        if (position == 0) {
            item_text.setEnabled(false);
        }
    }
    if (isChanged && (position == holdPosition) && !isItemShow) {
        item_text.setText("");
        item_text.setSelected(true);
        item_text.setEnabled(true);
        isChanged = false;
    }
    if (!isVisible && (position == -1 + selectedList.size())) {
        item_text.setText("");
        item_text.setSelected(true);
        item_text.setEnabled(true);
    }
    if (remove_position == position) {
        item_text.setText("");
    }
    return view;
}
 
Example 12
Project: oma-riista-android   File: EntryMapView.java   View Source Code Vote up 5 votes
private TextView setupCopyright() {
    // Display copyright text in bottom right corner
    TextView copyrightText = new TextView(getContext());
    copyrightText.setEnabled(false);
    copyrightText.setText(R.string.map_copyright_mml);
    copyrightText.setPadding(0, 0, 5, 0);
    copyrightText.setGravity(Gravity.BOTTOM | Gravity.RIGHT);

    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, copyrightText.getId());
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, copyrightText.getId());
    copyrightText.setLayoutParams(params);
    return copyrightText;
}
 
Example 13
Project: SuperNote   File: NoteMainActivity.java   View Source Code Vote up 5 votes
private void setButtonEnabled(boolean enabled, TextView view) {
    view.setEnabled(enabled);
    if (enabled) {
        view.setTextColor(getResources().getColor(R.color.white));
    } else {
        view.setTextColor(getResources().getColor(R.color.colorWhiteAlpha30));
    }
}
 
Example 14
Project: Phoenix-for-VK   File: AbsWallFragment.java   View Source Code Vote up 4 votes
protected static void setupCounter(TextView view, int count) {
    view.setText((count > 0 ? (AppTextUtils.getCounterWithK(count)) : "-"));
    view.setEnabled(count > 0);
}
 
Example 15
Project: godlibrary   File: CheckUtils.java   View Source Code Vote up 4 votes
/**
 * 不可编辑
 *
 * @param textViews
 */
public static void setEnabled(boolean enabled, TextView... textViews) {
    for (TextView e : textViews) {
        e.setEnabled(enabled);
    }
}
 
Example 16
Project: MultiContactPicker   File: MultiContactPickerActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    if (intent == null) return;

    builder = (MultiContactPicker.Builder) intent.getSerializableExtra("builder");

    setTheme(builder.theme);

    setContentView(R.layout.activity_multi_contact_picker);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    searchView = (MaterialSearchView) findViewById(R.id.search_view);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    tvSelectBtn = (TextView) findViewById(R.id.tvSelect);
    recyclerView = (FastScrollRecyclerView) findViewById(R.id.recyclerView);

    initialiseUI(builder);

    if(getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    recyclerView.setLayoutManager(new LinearLayoutManager(this));


    adapter = new MultiContactPickerAdapter(contactList, new MultiContactPickerAdapter.ContactSelectListener() {
        @Override
        public void onContactSelected(Contact contact, int totalSelectedContacts) {
            tvSelectBtn.setEnabled(totalSelectedContacts > 0);
            if(totalSelectedContacts > 0) {
                tvSelectBtn.setText(getString(R.string.tv_select_btn_text_enabled, String.valueOf(totalSelectedContacts)));
            } else {
                tvSelectBtn.setText(getString(R.string.tv_select_btn_text_disabled));
            }
        }
    });

    loadContacts();

    recyclerView.setAdapter(adapter);

    tvSelectBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent result = new Intent();
            result.putExtra(EXTRA_RESULT_SELECTION, MultiContactPicker.buildResult(adapter.getSelectedContacts()));
            setResult(RESULT_OK, result);
            finish();
        }
    });

}
 
Example 17
Project: chromium-for-android-56-debug-video   File: PaymentRequestSection.java   View Source Code Vote up 4 votes
private TextView createLabel(GridLayout parent, int rowIndex, boolean optionIconExists,
        boolean editIconExists, boolean isEnabled) {
    Context context = parent.getContext();
    Resources resources = context.getResources();

    // By default, the label appears to the right of the "button" in the second column.
    // + If there is no button, no option and edit icon, the label spans the whole row.
    // + If there is no option and edit icon, the label spans three columns.
    // + If there is no edit icon or option icon, the label spans two columns.
    // + Otherwise, the label occupies only its own column.
    int columnStart = 1;
    int columnSpan = 1;
    if (!optionIconExists) columnSpan++;
    if (!editIconExists) columnSpan++;

    TextView labelView = new TextView(context);
    if (mRowType == OPTION_ROW_TYPE_OPTION) {
        // Show the string representing the PaymentOption.
        ApiCompatibilityUtils.setTextAppearance(labelView, isEnabled
                ? R.style.PaymentsUiSectionDefaultText
                : R.style.PaymentsUiSectionDisabledText);
        labelView.setText(convertOptionToString(
                mOption, mDelegate.isBoldLabelNeeded(OptionSection.this)));
        labelView.setEnabled(isEnabled);
    } else if (mRowType == OPTION_ROW_TYPE_ADD) {
        // Shows string saying that the user can add a new option, e.g. credit card no.
        String typeface = resources.getString(R.string.roboto_medium_typeface);
        int textStyle = resources.getInteger(R.integer.roboto_medium_textstyle);
        int buttonHeight = resources.getDimensionPixelSize(
                R.dimen.payments_section_add_button_height);

        ApiCompatibilityUtils.setTextAppearance(
                labelView, R.style.PaymentsUiSectionAddButtonLabel);
        labelView.setMinimumHeight(buttonHeight);
        labelView.setGravity(Gravity.CENTER_VERTICAL);
        labelView.setTypeface(Typeface.create(typeface, textStyle));
    } else if (mRowType == OPTION_ROW_TYPE_DESCRIPTION) {
        // The description spans all the columns.
        columnStart = 0;
        columnSpan = 4;

        ApiCompatibilityUtils.setTextAppearance(
                labelView, R.style.PaymentsUiSectionDescriptiveText);
    } else if (mRowType == OPTION_ROW_TYPE_WARNING) {
        // Warnings use three columns.
        columnSpan = 3;
        ApiCompatibilityUtils.setTextAppearance(
                labelView, R.style.PaymentsUiSectionWarningText);
    }

    // The label spans two columns if no option or edit icon, or spans three columns if
    // no option and edit icons. Setting the view width to 0 forces it to stretch.
    GridLayout.LayoutParams labelParams = new GridLayout.LayoutParams(
            GridLayout.spec(rowIndex, 1, GridLayout.CENTER),
            GridLayout.spec(columnStart, columnSpan, GridLayout.FILL));
    labelParams.topMargin = mVerticalMargin;
    labelParams.width = 0;
    if (optionIconExists) {
        // Margin at the end of the label instead of the start of the option icon to
        // allow option icon in the the next row align with the end of label (include
        // end margin) when edit icon exits in that row, like below:
        // ---Label---------------------[label margin]|---option icon---|
        // ---Label---[label margin]|---option icon---|----edit icon----|
        ApiCompatibilityUtils.setMarginEnd(labelParams, mLargeSpacing);
    }
    parent.addView(labelView, labelParams);

    labelView.setOnClickListener(OptionSection.this);
    return labelView;
}
 
Example 18
Project: chromium-for-android-56-debug-video   File: BookmarkAddEditFolderActivity.java   View Source Code Vote up 4 votes
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mModel = new BookmarkModel();
    mModel.addObserver(mBookmarkModelObserver);
    mIsAddMode = getIntent().getBooleanExtra(INTENT_IS_ADD_MODE, false);
    if (mIsAddMode) {
        List<String> stringList = getIntent().getStringArrayListExtra(
                BookmarkFolderSelectActivity.INTENT_BOOKMARKS_TO_MOVE);
        mBookmarksToMove = new ArrayList<>(stringList.size());
        for (String string : stringList) {
            mBookmarksToMove.add(BookmarkId.getBookmarkIdFromString(string));
        }
    } else {
        mFolderId = BookmarkId.getBookmarkIdFromString(
                getIntent().getStringExtra(INTENT_BOOKMARK_ID));
    }
    setContentView(R.layout.bookmark_add_edit_folder_activity);

    mParentTextView = (TextView) findViewById(R.id.parent_folder);
    mFolderTitle = (EmptyAlertEditText) findViewById(R.id.folder_title);

    mParentTextView.setOnClickListener(this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if (mIsAddMode) {
        getSupportActionBar().setTitle(R.string.add_folder);
        updateParent(mModel.getDefaultFolder());
    } else {
        // Edit mode
        getSupportActionBar().setTitle(R.string.edit_folder);
        BookmarkItem bookmarkItem = mModel.getBookmarkById(mFolderId);
        updateParent(bookmarkItem.getParentId());
        mFolderTitle.setText(bookmarkItem.getTitle());
        mFolderTitle.setSelection(mFolderTitle.getText().length());
        mParentTextView.setEnabled(bookmarkItem.isMovable());
    }

    mParentTextView.setText(mModel.getBookmarkTitle(mParentId));
}
 
Example 19
Project: letv   File: LivePlayerController.java   View Source Code Vote up 4 votes
private void setBtnLevelStatus(int num) {
    boolean z;
    boolean z2 = true;
    this.mBtnLevelSmooth.setSelected(num == 0);
    TextView textView = this.mBtnLevelSmooth;
    if (num != 0) {
        z = true;
    } else {
        z = false;
    }
    textView.setEnabled(z);
    textView = this.mBtnLevelStandard;
    if (num == 1) {
        z = true;
    } else {
        z = false;
    }
    textView.setSelected(z);
    textView = this.mBtnLevelStandard;
    if (num != 1) {
        z = true;
    } else {
        z = false;
    }
    textView.setEnabled(z);
    textView = this.mBtnLevelHigh;
    if (num == 2) {
        z = true;
    } else {
        z = false;
    }
    textView.setSelected(z);
    textView = this.mBtnLevelHigh;
    if (num != 2) {
        z = true;
    } else {
        z = false;
    }
    textView.setEnabled(z);
    textView = this.mBtnLevelSuper;
    if (num == 3) {
        z = true;
    } else {
        z = false;
    }
    textView.setSelected(z);
    textView = this.mBtnLevelSuper;
    if (num != 3) {
        z = true;
    } else {
        z = false;
    }
    textView.setEnabled(z);
    textView = this.mBtnLevel2K;
    if (num == 4) {
        z = true;
    } else {
        z = false;
    }
    textView.setSelected(z);
    textView = this.mBtnLevel2K;
    if (num != 4) {
        z = true;
    } else {
        z = false;
    }
    textView.setEnabled(z);
    textView = this.mBtnLevel4K;
    if (num == 5) {
        z = true;
    } else {
        z = false;
    }
    textView.setSelected(z);
    TextView textView2 = this.mBtnLevel4K;
    if (num == 5) {
        z2 = false;
    }
    textView2.setEnabled(z2);
    this.mCurrentSelectLevelPos = num;
}
 
Example 20
Project: appinventor-extensions   File: TextViewUtil.java   View Source Code Vote up 2 votes
/**
 * Enables a {@link TextView}.
 *
 * @param textview   text view instance
 * @param enabled  {@code true} for enabled, {@code false} disabled
 */
public static void setEnabled(TextView textview, boolean enabled) {
  textview.setEnabled(enabled);
  textview.invalidate();
}