android.widget.TextView#setEnabled ( )源码实例Demo

下面列出了android.widget.TextView#setEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: BaoKanAndroid   文件: OptionalGridViewAdapter.java
@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) || (position == 1)) {
            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;
}
 
源代码2 项目: FixMath   文件: PlayActivity.java
void blockGoodAnswerFigures(String figureType){

            for (int i = Up; i <= Down; i++) {
                for (int x = 0; x <= 4; x++) {
                    String TextViewId = "var" + i + "x" + x;
                    int id = getResources().getIdentifier(TextViewId, "id", getPackageName());
                    TextView allTextContainer = (TextView) findViewById(id);
                    if(allTextContainer.getTag() != null) {
                        String containerTags = allTextContainer.getTag().toString();

                        if (containerTags.equals(figureType)) {
                            SetFiguresColor(allTextContainer, figureType);
                            allTextContainer.setEnabled(false);
                        }
                    }

                }
            }

    }
 
源代码3 项目: QMBForm   文件: FormTimeFieldCell.java
@Override
protected void updateDateLabel(Date date, boolean disabled) {

    DateFormat dateFormat = android.text.format.DateFormat.getTimeFormat(getContext());
    String s = dateFormat.format(date);

    TextView editView = getDetailTextView();
    editView.setText(s);

    if (disabled)
    {
        editView.setEnabled(false);
        setTextColor(editView, CellDescriptor.COLOR_VALUE_DISABLED);
    }

}
 
源代码4 项目: QMBForm   文件: FormButtonFieldCell.java
@Override
protected void update() {
    super.update();

    TextView textView = getTextView();
    setStyleId(getTextView(), CellDescriptor.APPEARANCE_BUTTON, CellDescriptor.COLOR_VALUE);

    if (getRowDescriptor().getDisabled())
    {
        setTextColor(textView, CellDescriptor.COLOR_VALUE_DISABLED);
        textView.setClickable(false);
        textView.setEnabled(false);

        setClickable(false);
        setEnabled(false);
    }
}
 
源代码5 项目: RxTools-master   文件: RxTool.java
/**
 * 倒计时
 *
 * @param textView 控件
 * @param waitTime 倒计时总时长
 * @param interval 倒计时的间隔时间
 * @param hint     倒计时完毕时显示的文字
 */
public static void countDown(final TextView textView, long waitTime, long interval, final String hint) {
    textView.setEnabled(false);
    android.os.CountDownTimer timer = new android.os.CountDownTimer(waitTime, interval) {

        @Override
        public void onTick(long millisUntilFinished) {
            textView.setText("剩下 " + (millisUntilFinished / 1000) + " S");
        }

        @Override
        public void onFinish() {
            textView.setEnabled(true);
            textView.setText(hint);
        }
    };
    timer.start();
}
 
源代码6 项目: LiuAGeAndroid   文件: OptionalGridViewAdapter.java
@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;
}
 
源代码7 项目: ResearchStack   文件: PermissionStepLayout.java
private void updatePermissionItems() {
    List<PermissionRequestManager.PermissionRequest> items = PermissionRequestManager.getInstance()
            .getPermissionRequests();

    for (PermissionRequestManager.PermissionRequest item : items) {
        boolean isGranted = PermissionRequestManager.getInstance().hasPermission(getContext(), item.getId());

        View parent = findViewWithTag(item.getId());

        TextView action = (TextView) parent.findViewById(R.id.permission_button);
        action.setText(isGranted
                ? R.string.rss_granted
                : item.isBlockingPermission() ? R.string.rss_allow : R.string.rss_optional);
        action.setEnabled(!isGranted);
    }
}
 
源代码8 项目: openboard   文件: SuggestionStripLayoutHelper.java
/**
 * 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.Companion.getInstance().isTouchExplorationEnabled());
    return wordView;
}
 
源代码9 项目: BehaviorCollect   文件: MyFragment.java
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mTvLogin = (TextView) getView().findViewById(R.id.login_btn);
    mTvLogin.setEnabled(false);//登录的按钮默认置灰。
    mTvLogin.setOnClickListener(this);
}
 
源代码10 项目: BehaviorCollect   文件: LoginFragment.java
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mTvLogin = (TextView) getView().findViewById(R.id.login_btn);
    mTvLogin.setEnabled(false);//登录的按钮默认置灰。
    mTvLogin.setOnClickListener(this);
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.zg_activity_media_show);
	mTV_catalog_name = (TextView) findViewById(R.id.tv_catalog_name);
	mTV_catalog_name.setOnClickListener(this);
	mTV_catalog_name.setEnabled(false);

	mTV_preview = (TextView) findViewById(R.id.tv_preview);
	mTV_preview.setOnClickListener(this);

	mTv_right = (TextView) findViewById(R.id.tv_right);
	mTv_right.setOnClickListener(this);

	findViewById(R.id.iv_left).setOnClickListener(this);

	initMode();

	mImageLoader = ImageLoader.getInstance();
	mGridView = (GridView) findViewById(R.id.gridview);
	mGridView.setFastScrollEnabled(true);
	PauseOnScrollListener listener = new PauseOnScrollListener(
			mImageLoader, true, true);
	mGridView.setOnScrollListener(listener);
	mMediaAdapter = new AdapterMediaShow(this, mediaType, mSelectedList);
	mGridView.setAdapter(mMediaAdapter);
	mGridView.setOnItemClickListener(this);

	new Thread(new getMediaInfoTask(null)).start();
}
 
/**
 * 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;
}
 
源代码13 项目: BaoKanAndroid   文件: DragGridViewAdapter.java
@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) || (position == 1)) {
            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;
}
 
源代码14 项目: Hentoid   文件: SearchActivity.java
/**
 * Update the text of a given attribute type button based on the given SparseIntArray and relevant type(s)
 *
 * @param button    Button whose text to update
 * @param attrCount Entry count in every attribute type (key = attribute type code; value = count)
 * @param types     Type(s) to fetch the count for
 */
private void updateAttributeTypeButton(@NonNull final TextView button, @NonNull final SparseIntArray attrCount, AttributeType... types) {
    if (0 == types.length) return;

    int count = 0;
    for (AttributeType type : types) count += attrCount.get(type.getCode(), 0);

    button.setText(format("%s (%s)", Helper.capitalizeString(types[0].getDisplayName()), count));
    button.setEnabled(count > 0);
}
 
源代码15 项目: AndroidChromium   文件: PaymentRequestSection.java
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;
}
 
private void setEnabled(@IdRes int resId, boolean enabled) {
  TextView view = findViewById(resId);
  view.setEnabled(enabled);
  view.setText("");
}
 
源代码17 项目: delion   文件: PaymentRequestSection.java
private TextView createLabel(
        GridLayout parent, int rowIndex, boolean iconExists, 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 and no icon, the label spans the whole row.
    // + If there is no icon, the label spans two columns.
    // + Otherwise, the label occupies only its own column.
    int columnStart = 1;
    int columnSpan = iconExists ? 1 : 2;

    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));
        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 = 3;

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

    // The label spans two columns if no icon exists.  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;
    parent.addView(labelView, labelParams);

    labelView.setOnClickListener(OptionSection.this);
    return labelView;
}
 
源代码18 项目: pandroid   文件: SnackbarManager.java
private ToastNotifier makeCustomNotification(Activity activity, ToastType toastType, String label, String btnLabel, int drawableRes, int style, int duration, boolean undefinedLoad, final ToastListener listener) {
    if (duration < 0)
        duration = Snackbar.LENGTH_INDEFINITE;
    final Snackbar notif = Snackbar.make(activity.findViewById(android.R.id.content), label, duration);
    if (style == 0) {
        style = R.style.Toast;
    }
    TypedArray attributes = activity.obtainStyledAttributes(style, R.styleable.ToastAppearance);
    int textColor = attributes.getColor(R.styleable.ToastAppearance_toastTextColor, ContextCompat.getColor(activity, R.color.white));
    int buttonTextColor = attributes.getColor(R.styleable.ToastAppearance_toastButtonTextColor, ContextCompat.getColor(activity, R.color.pandroid_green_dark));
    int backgroundColor = attributes.getColor(R.styleable.ToastAppearance_toastBackground, ContextCompat.getColor(activity, R.color.pandroid_green));
    notif.getView().setBackgroundColor(backgroundColor);
    ((TextView) notif.getView().findViewById(android.support.design.R.id.snackbar_text)).setTextColor(textColor);
    TextView actionView = ((TextView) notif.getView().findViewById(android.support.design.R.id.snackbar_action));
    actionView.setTextColor(buttonTextColor);
    attributes.recycle();

    notif.setCallback(new Snackbar.Callback() {
        @Override
        public void onDismissed(Snackbar snackbar, int event) {
            super.onDismissed(snackbar, event);
            if (listener != null)
                listener.onDismiss();
        }
    });

    Drawable drawable = null;
    if (drawableRes > 0) {
        drawable = ContextCompat.getDrawable(activity, drawableRes);
    }
    actionView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, drawable, null);
    if (toastType == ToastType.ACTION && btnLabel != null) {
        notif.setAction(btnLabel, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener != null)
                    listener.onActionClicked();
            }
        });
    } else if (drawableRes > 0) {
        actionView.setVisibility(View.VISIBLE);
        actionView.setClickable(false);
        actionView.setFocusableInTouchMode(false);
        actionView.setFocusable(false);
        actionView.setEnabled(false);
    }

    if (toastType == ToastType.LOADER) {
        ProgressWheel progressWheel = new ProgressWheel(activity);
        progressWheel.setId(R.id.snakebar_loader);
        if (undefinedLoad)
            progressWheel.spin();

        progressWheel.setBarWidth((int) DeviceUtils.dpToPx(activity, 4));
        progressWheel.setCircleRadius((int) DeviceUtils.dpToPx(activity, 30));
        progressWheel.setBarColor(buttonTextColor);
        progressWheel.setLinearProgress(true);
        ((Snackbar.SnackbarLayout) notif.getView()).addView(progressWheel, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
    }
    notif.show();
    lastShowNotif = notif;
    return new ToastNotifier() {
        @Override
        public void setProgress(int progress) {
            ProgressWheel loader = (ProgressWheel) notif.getView().findViewById(R.id.snakebar_loader);
            if (loader != null) {
                loader.setProgress(progress / 100f);
            }
        }

        @Override
        public void dismiss() {
            notif.dismiss();
        }

    };
}
 
源代码19 项目: letv   文件: LivePlayerController.java
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;
}
 
源代码20 项目: Android-Bootstrap   文件: BootstrapDropDown.java
private ScrollView createDropDownView() {
    final LinearLayout dropdownView = new LinearLayout(getContext());
    ScrollView scrollView = new ScrollView(getContext());
    int clickableChildCounter = 0;

    dropdownView.setOrientation(LinearLayout.VERTICAL);
    int height = (int) (itemHeight * bootstrapSize);
    LayoutParams childParams = new LayoutParams(LayoutParams.MATCH_PARENT, height);

    for (String text : dropdownData) {
        TextView childView = new TextView(getContext());
        childView.setGravity(Gravity.CENTER_VERTICAL);
        childView.setLayoutParams(childParams);

        int padding = (int) (baselineItemLeftPadding * bootstrapSize);
        childView.setPadding(padding, 0, padding, 0);
        childView.setTextSize(baselineDropDownViewFontSize * bootstrapSize);
        childView.setTextColor(ColorUtils.resolveColor(android.R.color.black, getContext()));

        Drawable background = getContext().obtainStyledAttributes(null, new int[]{
                android.R.attr.selectableItemBackground}, 0, 0)
                                        .getDrawable(0);
        ViewUtils.setBackgroundDrawable(childView, background);

        childView.setTextColor(BootstrapDrawableFactory.bootstrapDropDownViewText(getContext()));
        childView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dropdownWindow.dismiss();
                if (onDropDownItemClickListener != null) {
                    onDropDownItemClickListener.onItemClick(dropdownView, v, v.getId());
                }
            }
        });

        if (Pattern.matches(SEARCH_REGEX_HEADER, text)) {
            childView.setText(text.replaceFirst(REPLACE_REGEX_HEADER, ""));
            childView.setTextSize((baselineDropDownViewFontSize - 2F) * bootstrapSize);
            childView.setClickable(false);
            childView.setTextColor(ColorUtils.resolveColor(R.color.bootstrap_gray_light,
                                                           getContext()));
        }
        else if (Pattern.matches(SEARCH_REGEX_SEPARATOR, text)) {
            childView = new DividerView(getContext());
            childView.setClickable(false);
            childView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 3));
        }
        else if (Pattern.matches(SEARCH_REGEX_DISABLED, text)) {
            childView.setEnabled(false);
            childView.setId(clickableChildCounter++);
            childView.setText(text.replaceFirst(REPLACE_REGEX_DISABLED, ""));
        }
        else {
            childView.setText(text);
            childView.setId(clickableChildCounter++);
        }
        dropdownView.addView(childView);
    }

    dropdownView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    dropDownViewHeight = dropdownView.getMeasuredHeight();
    dropDownViewWidth = dropdownView.getMeasuredWidth();

    scrollView.setVerticalScrollBarEnabled(false);
    scrollView.setHorizontalScrollBarEnabled(false);
    scrollView.addView(dropdownView);

    cleanData();
    return scrollView;
}
 
 方法所在类
 同类方法