Java Code Examples for androidx.appcompat.widget.AppCompatTextView

The following examples show how to use androidx.appcompat.widget.AppCompatTextView. These examples are extracted from open source projects. 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 Project: onpc   Author: mkulesh   File: MainNavigationDrawer.java    License: GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #2
Source Project: SAI   Author: Aefyr   File: ThemeView.java    License: GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #3
Source Project: Beedio   Author: hikikomoriphoenix   File: VideoList.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #4
Source Project: Markwon   Author: noties   File: PrecomputedFutureTextSetterCompat.java    License: Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example #5
Source Project: SimplicityBrowser   Author: creativetrendsapps   File: WelcomeActivity.java    License: MIT License 6 votes vote down vote up
@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));
}
 
Example #6
Source Project: SimplicityBrowser   Author: creativetrendsapps   File: Cardbar.java    License: MIT License 6 votes vote down vote up
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;
}
 
Example #7
Source Project: material-components-android   Author: material-components   File: CoordinatorSnackbarWithFabTest.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #8
Source Project: material-components-android   Author: material-components   File: CoordinatorSnackbarWithFabTest.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #9
Source Project: material-components-android   Author: material-components   File: CoordinatorSnackbarWithFabTest.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #10
Source Project: material-components-android   Author: material-components   File: TextInputLayout.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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;
  }
}
 
Example #11
Source Project: material-components-android   Author: material-components   File: TextInputLayout.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #12
SelectionOptionViewHolder(@NonNull View itemView, @NonNull Consumer<Integer> onClick) {
  super(itemView);
  itemView.setOnClickListener(v -> {
    if (getAdapterPosition() != RecyclerView.NO_POSITION) {
      onClick.accept(getAdapterPosition());
    }
  });

  optionView = (AppCompatTextView) itemView;
}
 
Example #13
Source Project: mollyim-android   Author: mollyim   File: WebRtcCallActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
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();
}
 
Example #14
Source Project: AndroidFastScroll   Author: zhanghai   File: FastScroller.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #15
Source Project: GetApk   Author: kingwang666   File: DetailActivity.java    License: MIT License 5 votes vote down vote up
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);
}
 
Example #16
Source Project: GetApk   Author: kingwang666   File: DetailActivity.java    License: MIT License 5 votes vote down vote up
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);
}
 
Example #17
Source Project: GetApk   Author: kingwang666   File: DetailActivity.java    License: MIT License 5 votes vote down vote up
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);
}
 
Example #18
Source Project: Gander   Author: Ashok-Varma   File: TransactionPayloadFragment.java    License: Apache License 2.0 5 votes vote down vote up
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;
                }
            });
        }
    }
 
Example #19
Source Project: CrazyDaily   Author: crazysunj   File: PhotoPickerAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@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);
        }
    });
}
 
Example #20
Source Project: MTweaks-KernelAdiutorMOD   Author: morogoku   File: ProgressBarView.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #21
@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();
}
 
Example #22
Source Project: mimi-reader   Author: MimiReader   File: FilterListAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public FilterViewHolder(View itemView) {
    super(itemView);

    root = itemView;
    name = (AppCompatTextView) itemView.findViewById(R.id.filter_name);
    regex = (AppCompatTextView) itemView.findViewById(R.id.filter_regex);
}
 
Example #23
Source Project: material-components-android   Author: material-components   File: BottomSheetDialogFragmentDismissTest.java    License: Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #24
Source Project: material-components-android   Author: material-components   File: BottomSheetDialogTest.java    License: Apache License 2.0 5 votes vote down vote up
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();
      });
}
 
Example #25
Source Project: material-components-android   Author: material-components   File: IndicatorViewController.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #26
Source Project: material-components-android   Author: material-components   File: IndicatorViewController.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #27
Source Project: hipda   Author: GreenSkinMonster   File: DownloadManagerResolver.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #28
Source Project: ProjectX   Author: AlexMofer   File: StateLayoutActivity.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #29
Source Project: ProjectX   Author: AlexMofer   File: HeaderFooterGridViewActivity.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #30
Source Project: ProjectX   Author: AlexMofer   File: ViewHolder.java    License: Apache License 2.0 5 votes vote down vote up
ViewHolder(ViewGroup parent) {
    super(new AppCompatTextView(parent.getContext()));
    mVText = (AppCompatTextView) itemView;
    mVText.setGravity(Gravity.CENTER);
    mVText.setBackgroundColor(0xff00dd00);
    mVText.setTextColor(0xffffffff);
}