类androidx.appcompat.widget.AppCompatTextView源码实例Demo

下面列出了怎么用androidx.appcompat.widget.AppCompatTextView的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: onpc   文件: MainNavigationDrawer.java
private void updateItem(@NonNull final MenuItem m, final @DrawableRes int iconId, final String title, final ButtonListener editListener)
{
    if (m.getActionView() != null && m.getActionView() instanceof LinearLayout)
    {
        final LinearLayout l = (LinearLayout)m.getActionView();
        ((AppCompatImageView) l.findViewWithTag("ICON")).setImageResource(iconId);
        ((AppCompatTextView)l.findViewWithTag("TEXT")).setText(title);
        final AppCompatImageButton editBtn = l.findViewWithTag("EDIT");
        if (editListener != null)
        {
            editBtn.setVisibility(View.VISIBLE);
            editBtn.setOnClickListener(v -> editListener.onEditItem());
            Utils.setButtonEnabled(activity, editBtn, true);
        }
        else
        {
            editBtn.setVisibility(View.GONE);
        }
    }
    m.setVisible(true);
}
 
源代码2 项目: SAI   文件: ThemeView.java
private void init() {
    LinearLayoutCompat container = new LinearLayoutCompat(getContext());
    container.setOrientation(LinearLayoutCompat.VERTICAL);
    MaterialCardView.LayoutParams containerLayoutParams = new MaterialCardView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    containerLayoutParams.gravity = Gravity.CENTER;
    addView(container, containerLayoutParams);

    mThemeTitle = new AppCompatTextView(getContext());
    mThemeTitle.setGravity(Gravity.CENTER);
    mThemeTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
    LinearLayoutCompat.LayoutParams titleLayoutParams = new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    container.addView(mThemeTitle, titleLayoutParams);

    mThemeMessage = new AppCompatTextView(getContext());
    mThemeMessage.setGravity(Gravity.CENTER);
    mThemeMessage.setVisibility(GONE);
    LinearLayoutCompat.LayoutParams messageLayoutParams = new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    container.addView(mThemeMessage, messageLayoutParams);
}
 
源代码3 项目: Beedio   文件: VideoList.java
void bind(Video video) {
    if (video.size != null) {
        String sizeFormatted = Formatter.formatShortFileSize(activity,
                Long.parseLong(video.size));
        size.setText(sizeFormatted);
    } else size.setText(" ");
    String extStr = "." + video.type;
    ext.setText(extStr);
    check.setChecked(video.checked);
    name.setText(video.name);
    if (video.expanded) {
        expand.setVisibility(View.VISIBLE);
        AppCompatTextView detailsText = expand.findViewById(R.id.videoFoundDetailsText);
        detailsText.setVisibility(View.VISIBLE);
        detailsText.setText(video.details);
    } else {
        expand.setVisibility(View.GONE);
    }
    expand.findViewById(R.id.videoFoundRename).setOnClickListener(this);
    expand.findViewById(R.id.videoFoundDownload).setOnClickListener(this);
    expand.findViewById(R.id.videoFoundDelete).setOnClickListener(this);
    expand.findViewById(R.id.videoFoundDetailsBtn).setOnClickListener(this);
}
 
@Override
public void setText(
        @NonNull TextView textView,
        @NonNull Spanned markdown,
        @NonNull TextView.BufferType bufferType,
        @NonNull Runnable onComplete) {
    if (textView instanceof AppCompatTextView) {
        final AppCompatTextView appCompatTextView = (AppCompatTextView) textView;
        final Future<PrecomputedTextCompat> future = PrecomputedTextCompat.getTextFuture(
                markdown,
                appCompatTextView.getTextMetricsParamsCompat(),
                executor);
        appCompatTextView.setTextFuture(future);
        // `setTextFuture` is actually a synchronous call, so we should call onComplete now
        onComplete.run();
    } else {
        throw new IllegalStateException("TextView provided is not an instance of AppCompatTextView, " +
                "cannot call setTextFuture(), textView: " + textView);
    }
}
 
源代码5 项目: SimplicityBrowser   文件: WelcomeActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_welcome);
    prefManager = new PrefManager(this);
    MaterialButton appCompatButton = findViewById(R.id.wel_button);
    AppCompatTextView termsTextView = findViewById(R.id.wel_term);
    AppCompatTextView policyTextView = findViewById(R.id.wel_pri);
    appCompatButton.setOnClickListener(this);
    termsTextView.setOnClickListener(this);
    policyTextView.setOnClickListener(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
        getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.white));
    }else{
        getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.black));
    }
    getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.black));
}
 
源代码6 项目: SimplicityBrowser   文件: Cardbar.java
public static @CheckResult
    Toast snackBar(Context context, CharSequence message_to_show, boolean duration) {
    @SuppressLint("InflateParams")
    View view = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.custom_snackbar, null);
    AppCompatTextView message = view.findViewById(R.id.message);
    message.setText(message_to_show);
    Toast toast = new Toast(context);
    toast.setView(view);
    toast.setGravity(Gravity.FILL_HORIZONTAL | Gravity.BOTTOM, 0, 0);
    if (duration) {
        toast.setDuration(Toast.LENGTH_LONG);
    } else {
        toast.setDuration(Toast.LENGTH_SHORT);
    }
    return toast;
}
 
@Test
public void testBehaviorBasedSlidingFromLayoutAttribute() {
  // Use a layout in which an AppCompatTextView child has Behavior object configured via
  // layout_behavior XML attribute
  onView(withId(R.id.coordinator_stub))
      .perform(inflateViewStub(R.layout.design_snackbar_behavior_layout_attr));

  // Create and show a snackbar
  snackbar =
      Snackbar.make(mCoordinatorLayout, MESSAGE_TEXT, Snackbar.LENGTH_INDEFINITE)
          .setAction(ACTION_TEXT, mock(View.OnClickListener.class));
  SnackbarUtils.showTransientBottomBarAndWaitUntilFullyShown(snackbar);

  final AppCompatTextView textView = mCoordinatorLayout.findViewById(R.id.text);
  verifySnackbarViewStacking(textView, 0);
}
 
@Test
public void testBehaviorBasedSlidingFromClassAnnotation() {
  // Use a layout in which a custom child view has Behavior object configured via
  // annotation on the class that extends AppCompatTextView
  onView(withId(R.id.coordinator_stub))
      .perform(inflateViewStub(R.layout.design_snackbar_behavior_annotation));

  // Create and show a snackbar
  snackbar =
      Snackbar.make(mCoordinatorLayout, MESSAGE_TEXT, Snackbar.LENGTH_INDEFINITE)
          .setAction(ACTION_TEXT, mock(View.OnClickListener.class));
  SnackbarUtils.showTransientBottomBarAndWaitUntilFullyShown(snackbar);

  final AppCompatTextView textView = mCoordinatorLayout.findViewById(R.id.text);
  verifySnackbarViewStacking(textView, 0);
}
 
@Test
public void testBehaviorBasedSlidingFromRuntimeApiCall() {
  // Use a layout in which an AppCompatTextView child doesn't have any configured Behavior
  onView(withId(R.id.coordinator_stub))
      .perform(inflateViewStub(R.layout.design_snackbar_behavior_runtime));

  // and configure that Behavior at runtime by setting it on its LayoutParams
  final AppCompatTextView textView = mCoordinatorLayout.findViewById(R.id.text);
  final CoordinatorLayout.LayoutParams textViewLp =
      (CoordinatorLayout.LayoutParams) textView.getLayoutParams();
  textViewLp.setBehavior(new TestFloatingBehavior());

  // Create and show a snackbar
  snackbar =
      Snackbar.make(mCoordinatorLayout, MESSAGE_TEXT, Snackbar.LENGTH_INDEFINITE)
          .setAction(ACTION_TEXT, mock(View.OnClickListener.class));
  SnackbarUtils.showTransientBottomBarAndWaitUntilFullyShown(snackbar);

  verifySnackbarViewStacking(textView, 0);
}
 
/**
 * Whether the character counter functionality is enabled or not in this layout.
 *
 * @attr ref com.google.android.material.R.styleable#TextInputLayout_counterEnabled
 */
public void setCounterEnabled(boolean enabled) {
  if (counterEnabled != enabled) {
    if (enabled) {
      counterView = new AppCompatTextView(getContext());
      counterView.setId(R.id.textinput_counter);
      if (typeface != null) {
        counterView.setTypeface(typeface);
      }
      counterView.setMaxLines(1);
      indicatorViewController.addIndicator(counterView, COUNTER_INDEX);
      MarginLayoutParamsCompat.setMarginStart(
          (MarginLayoutParams) counterView.getLayoutParams(),
          getResources().getDimensionPixelOffset(R.dimen.mtrl_textinput_counter_margin_start));
      updateCounterTextAppearanceAndColor();
      updateCounter();
    } else {
      indicatorViewController.removeIndicator(counterView, COUNTER_INDEX);
      counterView = null;
    }
    counterEnabled = enabled;
  }
}
 
private void setPlaceholderTextEnabled(boolean placeholderEnabled) {
  // If the enabled state is the same as before, do nothing.
  if (this.placeholderEnabled == placeholderEnabled) {
    return;
  }

  // Otherwise, adjust enabled state.
  if (placeholderEnabled) {
    placeholderTextView = new AppCompatTextView(getContext());
    placeholderTextView.setId(R.id.textinput_placeholder);

    ViewCompat.setAccessibilityLiveRegion(
        placeholderTextView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);

    setPlaceholderTextAppearance(placeholderTextAppearance);
    setPlaceholderTextColor(placeholderTextColor);
    addPlaceholderTextView();
  } else {
    removePlaceholderTextView();
    placeholderTextView = null;
  }
  this.placeholderEnabled = placeholderEnabled;
}
 
SelectionOptionViewHolder(@NonNull View itemView, @NonNull Consumer<Integer> onClick) {
  super(itemView);
  itemView.setOnClickListener(v -> {
    if (getAdapterPosition() != RecyclerView.NO_POSITION) {
      onClick.accept(getAdapterPosition());
    }
  });

  optionView = (AppCompatTextView) itemView;
}
 
源代码13 项目: mollyim-android   文件: WebRtcCallActivity.java
private void handleUntrustedIdentity(@NonNull WebRtcViewModel event) {
  final IdentityKey theirKey  = event.getIdentityKey();
  final Recipient   recipient = event.getRecipient();

  if (theirKey == null) {
    handleTerminate(recipient, HangupMessage.Type.NORMAL);
  }

  String          name            = recipient.getDisplayName(this);
  String          introduction    = getString(R.string.WebRtcCallScreen_new_safety_numbers, name, name);
  SpannableString spannableString = new SpannableString(introduction + " " + getString(R.string.WebRtcCallScreen_you_may_wish_to_verify_this_contact));

  spannableString.setSpan(new VerifySpan(this, recipient.getId(), theirKey), introduction.length() + 1, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

  AppCompatTextView untrustedIdentityExplanation = new AppCompatTextView(this);
  untrustedIdentityExplanation.setText(spannableString);
  untrustedIdentityExplanation.setMovementMethod(LinkMovementMethod.getInstance());

  new AlertDialog.Builder(this)
                 .setView(untrustedIdentityExplanation)
                 .setPositiveButton(R.string.WebRtcCallScreen_accept, (d, w) -> {
                   synchronized (SESSION_LOCK) {
                     TextSecureIdentityKeyStore identityKeyStore = new TextSecureIdentityKeyStore(WebRtcCallActivity.this);
                     identityKeyStore.saveIdentity(new SignalProtocolAddress(recipient.requireServiceId(), 1), theirKey, true);
                   }

                   d.dismiss();

                   Intent intent = new Intent(WebRtcCallActivity.this, WebRtcCallService.class);
                   intent.setAction(WebRtcCallService.ACTION_OUTGOING_CALL)
                         .putExtra(WebRtcCallService.EXTRA_REMOTE_PEER, new RemotePeer(recipient.getId()));

                   startService(intent);
                 })
                 .setNegativeButton(R.string.WebRtcCallScreen_end_call, (d, w) -> {
                   d.dismiss();
                   handleTerminate(recipient, HangupMessage.Type.NORMAL);
                 })
                 .show();
}
 
源代码14 项目: AndroidFastScroll   文件: FastScroller.java
public FastScroller(@NonNull ViewGroup view, @NonNull ViewHelper viewHelper,
                    @Nullable Rect padding, @NonNull Drawable trackDrawable,
                    @NonNull Drawable thumbDrawable, @NonNull Consumer<TextView> popupStyle,
                    @NonNull AnimationHelper animationHelper) {

    mMinTouchTargetSize = view.getResources().getDimensionPixelSize(
            R.dimen.afs_min_touch_target_size);
    Context context = view.getContext();
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mView = view;
    mViewHelper = viewHelper;
    mUserPadding = padding;
    mAnimationHelper = animationHelper;

    mTrackWidth = trackDrawable.getIntrinsicWidth();
    mThumbWidth = thumbDrawable.getIntrinsicWidth();
    mThumbHeight = thumbDrawable.getIntrinsicHeight();

    mTrackView = new View(context);
    mTrackView.setBackground(trackDrawable);
    mThumbView = new View(context);
    mThumbView.setBackground(thumbDrawable);
    mPopupView = new AppCompatTextView(context);
    mPopupView.setLayoutParams(new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    popupStyle.accept(mPopupView);

    ViewGroupOverlay overlay = mView.getOverlay();
    overlay.add(mTrackView);
    overlay.add(mThumbView);
    overlay.add(mPopupView);

    postAutoHideScrollbar();
    mPopupView.setAlpha(0);

    mViewHelper.addOnPreDrawListener(this::onPreDraw);
    mViewHelper.addOnScrollChangedListener(this::onScrollChanged);
    mViewHelper.addOnTouchEventListener(this::onTouchEvent);
}
 
源代码15 项目: GetApk   文件: DetailActivity.java
private void addChildView(String str) {
    AppCompatTextView textView = new AppCompatTextView(this);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMarginStart(SizeUtil.dp2pxSize(this, 6));
    params.topMargin = SizeUtil.dp2pxSize(this, 4);
    textView.setTextIsSelectable(true);
    textView.setText(str);
    mInfoParent.addView(textView, params);
}
 
源代码16 项目: GetApk   文件: DetailActivity.java
private void addParentView(String str) {
    AppCompatTextView textView = new AppCompatTextView(this);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.topMargin = SizeUtil.dp2pxSize(this, 8);
    textView.setTextSize(15);
    textView.setText(str);
    textView.setTextColor(ContextCompat.getColor(this, R.color.colorPrimary));
    mInfoParent.addView(textView, params);
}
 
源代码17 项目: GetApk   文件: DetailActivity.java
private void addParent2View(String str) {
    AppCompatTextView textView = new AppCompatTextView(this);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.topMargin = SizeUtil.dp2pxSize(this, 4);
    params.setMarginStart(SizeUtil.dp2pxSize(this, 6));
    textView.setTextSize(15);
    textView.setText(str);
    textView.setTextColor(ContextCompat.getColor(this, R.color.blue500));
    mInfoParent.addView(textView, params);
}
 
源代码18 项目: Gander   文件: TransactionPayloadFragment.java
private void populateBody(boolean isPlainText) {
        if (!isPlainText) {
            mBodyView.setText(getString(R.string.gander_body_omitted));
        } else {
//            mExecutor.shutdown();
            TextUtil.asyncSetText(mExecutor, new TextUtil.AsyncTextProvider() {
                @Override
                public CharSequence getText() {
                    CharSequence body = null;
                    String searchKey = mSearchKey;
                    if (mType == TYPE_REQUEST) {
                        body = mTransactionUIHelper.getFormattedRequestBody();
                    } else if (mType == TYPE_RESPONSE) {
                        body = mTransactionUIHelper.getFormattedResponseBody();
                    }
                    if (TextUtil.isNullOrWhiteSpace(body) || TextUtil.isNullOrWhiteSpace(searchKey)) {
                        return body;
                    } else {
                        List<Integer> startIndexes = FormatUtils.indexOf(body, searchKey);
                        SpannableString spannableBody = new SpannableString(body);
                        FormatUtils.applyHighlightSpan(spannableBody, startIndexes, searchKey.length());
                        mBodySearchIndices = startIndexes;
                        return spannableBody;
                    }
                }

                @Override
                public AppCompatTextView getTextView() {
                    return mBodyView;
                }
            });
        }
    }
 
源代码19 项目: CrazyDaily   文件: PhotoPickerAdapter.java
@Override
protected void convert(@NonNull BaseViewHolder holder, MediaEntity item) {
    AppCompatImageView data = holder.getView(R.id.item_photo_picker_data, AppCompatImageView.class);
    ImageLoader.load(mContext, item.getData(), R.mipmap.ic_launcher, data);
    // 选中
    AppCompatTextView select = holder.getView(R.id.item_photo_picker_select, AppCompatTextView.class);
    final int index = item.getIndex();
    if (index > 0) {
        // 选中
        select.setSelected(true);
        select.setText(String.valueOf(index));
    } else {
        select.setSelected(false);
        select.setText(R.string.ic_tick);
    }
    View video = holder.getView(R.id.item_photo_picker_video);
    // 视频信息
    final long duration = item.getDuration();
    if (duration > 0) {
        // 视频
        video.setVisibility(View.VISIBLE);
        AppCompatTextView durationView = holder.getView(R.id.item_photo_picker_duration, AppCompatTextView.class);
        durationView.setText(StringUtil.handleTimeStringByMilli(duration));
    } else {
        video.setVisibility(View.GONE);
    }
    // 监听
    holder.getView(R.id.item_photo_picker_select_wrap).setOnClickListener(v -> {
        if (mOnItemSelectClickListener != null) {
            mOnItemSelectClickListener.onItemSelectClick(item);
        }
    });
    holder.itemView.setOnClickListener(v -> {
        if (mOnItemClickListener != null) {
            mOnItemClickListener.onItemClick(item);
        }
    });
}
 
源代码20 项目: MTweaks-KernelAdiutorMOD   文件: ProgressBarView.java
@Override
public void onCreateView(final View view) {

    mProgressBar = (RoundCornerProgressBar) view.findViewById(R.id.progressbar);
    mTitle = (AppCompatTextView) view.findViewById(R.id.title);
    mTotal = (AppCompatTextView) view.findViewById(R.id.total);
    mUsed = (AppCompatTextView) view.findViewById(R.id.used);
    mUsedLabel = (AppCompatTextView) view.findViewById(R.id.used_label);
    mFree = (AppCompatTextView) view.findViewById(R.id.free);
    mFreeLabel = (AppCompatTextView) view.findViewById(R.id.free_label);
    mPercent = (AppCompatTextView) view.findViewById(R.id.percent);

    super.onCreateView(view);
}
 
@Override
protected void onFinishInflate(){
    super.onFinishInflate();
    mVerticalSeekBar = findViewById(R.id.eqseekbar);
    mVerticalSeekBar.grxSetInitialized(false);
    mVerticalSeekBar.setOnSeekBarChangeListener(this);
    mValueTextView = findViewById(R.id.value);

    TextView bandview = (AppCompatTextView) findViewById(R.id.band);
    String[] bands = getResources().getStringArray(R.array.equalizerbands);
    bandview.setText(String.valueOf(  bands[mBandId]    ));
    updateSeekBar();
}
 
源代码22 项目: mimi-reader   文件: FilterListAdapter.java
public FilterViewHolder(View itemView) {
    super(itemView);

    root = itemView;
    name = (AppCompatTextView) itemView.findViewById(R.id.filter_name);
    regex = (AppCompatTextView) itemView.findViewById(R.id.filter_regex);
}
 
@Override
public View onCreateView(
    LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  AppCompatTextView text = new AppCompatTextView(getContext());
  StringBuilder builder = new StringBuilder();
  builder.append("It is fine today.");
  text.setText(builder);
  return text;
}
 
private void showDialog() throws Throwable {
  activityTestRule.runOnUiThread(
      () -> {
        Context context = activityTestRule.getActivity();
        dialog = new BottomSheetDialog(context);
        AppCompatTextView text = new AppCompatTextView(context);
        StringBuilder builder = new StringBuilder();
        builder.append("It is fine today. ");
        text.setText(builder);
        dialog.setContentView(text);
        dialog.show();
      });
}
 
void setErrorEnabled(boolean enabled) {
  // If the enabled state is the same as before, do nothing.
  if (errorEnabled == enabled) {
    return;
  }

  // Otherwise, adjust enabled state.
  cancelCaptionAnimator();

  if (enabled) {
    errorView = new AppCompatTextView(context);
    errorView.setId(R.id.textinput_error);
    if (VERSION.SDK_INT >= 17) {
      errorView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
    }
    if (typeface != null) {
      errorView.setTypeface(typeface);
    }
    setErrorTextAppearance(errorTextAppearance);
    setErrorViewTextColor(errorViewTextColor);
    setErrorContentDescription(errorViewContentDescription);
    errorView.setVisibility(View.INVISIBLE);
    ViewCompat.setAccessibilityLiveRegion(errorView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
    addIndicator(errorView, ERROR_INDEX);
  } else {
    hideError();
    removeIndicator(errorView, ERROR_INDEX);
    errorView = null;
    textInputView.updateEditTextBackground();
    textInputView.updateTextInputBoxState();
  }
  errorEnabled = enabled;
}
 
void setHelperTextEnabled(boolean enabled) {
  // If the enabled state is the same as before, do nothing.
  if (helperTextEnabled == enabled) {
    return;
  }

  // Otherwise, adjust enabled state.
  cancelCaptionAnimator();

  if (enabled) {
    helperTextView = new AppCompatTextView(context);
    helperTextView.setId(R.id.textinput_helper_text);
    if (VERSION.SDK_INT >= 17) {
      helperTextView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
    }
    if (typeface != null) {
      helperTextView.setTypeface(typeface);
    }
    helperTextView.setVisibility(View.INVISIBLE);
    ViewCompat.setAccessibilityLiveRegion(
        helperTextView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
    setHelperTextAppearance(helperTextTextAppearance);
    setHelperTextViewTextColor(helperTextViewTextColor);
    addIndicator(helperTextView, HELPER_INDEX);
  } else {
    hideHelperText();
    removeIndicator(helperTextView, HELPER_INDEX);
    helperTextView = null;
    textInputView.updateEditTextBackground();
    textInputView.updateTextInputBoxState();
  }
  helperTextEnabled = enabled;
}
 
源代码27 项目: hipda   文件: DownloadManagerResolver.java
private static AlertDialog createDialog(final Context context) {
    AppCompatTextView messageTextView = new AppCompatTextView(context);
    messageTextView.setTextSize(16f);
    messageTextView.setText("下载管理器已停用,请启用");
    return new AlertDialog.Builder(context)
            .setView(messageTextView, 50, 30, 50, 30)
            .setPositiveButton(context.getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    enableDownloadManager(context);
                }
            })
            .setCancelable(false)
            .create();
}
 
源代码28 项目: ProjectX   文件: StateLayoutActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setSupportActionBar(R.id.sl_toolbar);
    mVState = findViewById(R.id.sl_lyt_state);
    final RadioGroup state = findViewById(R.id.sl_rg_state);
    final RadioGroup mode = findViewById(R.id.sl_rg_mode);
    mDLoading = ContextCompat.getDrawable(this, R.drawable.ic_statelayout_loading);
    mDError = ContextCompat.getDrawable(this, R.drawable.ic_statelayout_error);
    mDEmpty = ContextCompat.getDrawable(this, R.drawable.ic_statelayout_empty);
    final CircularProgressImageView loading = new CircularProgressImageView(this);
    loading.setColorSchemeColors(
            ContextCompat.getColor(this, android.R.color.holo_red_light),
            ContextCompat.getColor(this, android.R.color.holo_blue_light),
            ContextCompat.getColor(this, android.R.color.holo_green_light),
            ContextCompat.getColor(this, android.R.color.holo_orange_light),
            ContextCompat.getColor(this, android.R.color.holo_purple));
    mVLoading = loading;
    final AppCompatTextView error = new AppCompatTextView(this);
    error.setText(R.string.sl_change_state_error);
    error.setTextColor(0xffff4081);
    error.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 64);
    mVError = error;
    final AppCompatTextView empty = new AppCompatTextView(this);
    empty.setText(R.string.sl_change_state_empty);
    empty.setTextColor(0xff092d6d);
    empty.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 64);
    mVEmpty = empty;

    state.setOnCheckedChangeListener(this);
    state.check(R.id.sl_rb_normal);
    mode.setOnCheckedChangeListener(this);
    mode.check(R.id.sl_rb_drawable);

    mVState.setOnClickListener(this);
}
 
源代码29 项目: ProjectX   文件: HeaderFooterGridViewActivity.java
private AppCompatTextView createTextView(Context context) {
    final float density = context.getResources().getDisplayMetrics().density;
    AppCompatTextView text = new AppCompatTextView(context);
    text.setTextColor(0xff999999);
    text.setGravity(Gravity.CENTER);
    text.setMinimumWidth((int) (64 * density));
    text.setMinimumHeight((int) (48 * density));
    text.setBackgroundResource(R.drawable.bg_headerfootergridview_item);
    return text;
}
 
源代码30 项目: ProjectX   文件: ViewHolder.java
ViewHolder(ViewGroup parent) {
    super(new AppCompatTextView(parent.getContext()));
    mVText = (AppCompatTextView) itemView;
    mVText.setGravity(Gravity.CENTER);
    mVText.setBackgroundColor(0xff00dd00);
    mVText.setTextColor(0xffffffff);
}