Java Code Examples for androidx.appcompat.widget.AppCompatTextView#setText()

The following examples show how to use androidx.appcompat.widget.AppCompatTextView#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VideoList.java    From Beedio with 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 2
Source File: Cardbar.java    From SimplicityBrowser with 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 3
Source File: WebRtcCallActivity.java    From mollyim-android with 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 4
Source File: DetailActivity.java    From GetApk with 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 5
Source File: DetailActivity.java    From GetApk with 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 6
Source File: DetailActivity.java    From GetApk with 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 7
Source File: PhotoPickerAdapter.java    From CrazyDaily with 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 8
Source File: BottomSheetDialogFragmentDismissTest.java    From material-components-android with 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 9
Source File: DownloadManagerResolver.java    From hipda with 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 10
Source File: StateLayoutActivity.java    From ProjectX with 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 11
Source File: NewSimplicityAccount.java    From SimplicityBrowser with MIT License 4 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    if(UserPreferences.getBoolean("dark_mode", false)){
        setTheme(R.style.SimplicityAccountThemeDark);
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_create_account);
    editText0 = findViewById(R.id.name_edit);
    editText1 = findViewById(R.id.email_edit);
    editText2 = findViewById(R.id.password_edit);
    next = findViewById(R.id.next_button);
    verify = findViewById(R.id.verify_button);
    forgot = findViewById(R.id.forgot_pass);
    toolbar = findViewById(R.id.toolbar);
    appCompatImageView = findViewById(R.id.account_picture);
    setSupportActionBar(toolbar);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        getSupportActionBar().setDisplayShowHomeEnabled(false);
        getSupportActionBar().setTitle(null);
    }

    Calendar calendar = Calendar.getInstance();
    int year = calendar.get(Calendar.YEAR);
    AppCompatTextView copyright = findViewById(R.id.copy);
    copyright.setText("");
    try {
        appCompatImageView.setOnClickListener(v -> showImageChooser());
        next.setOnClickListener(v -> createAccount(Objects.requireNonNull(editText0.getText()).toString(), Objects.requireNonNull(editText1.getText()).toString(), Objects.requireNonNull(editText2.getText()).toString()));
        forgot.setOnClickListener(v -> resetPass(Objects.requireNonNull(editText1.getText()).toString()));
        editText2.setOnKeyListener((v, keyCode, event) -> {
            if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) {
                createAccount(Objects.requireNonNull(editText0.getText()).toString(), Objects.requireNonNull(editText1.getText()).toString(), Objects.requireNonNull(editText2.getText()).toString());
                return true;
            }
            return false;
        });
    }catch (NullPointerException i){
        i.printStackTrace();
    }catch (Exception ignored){

    }

}
 
Example 12
Source File: SimplicityAccount.java    From SimplicityBrowser with MIT License 4 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    if(UserPreferences.getBoolean("dark_mode", false)){
        setTheme(R.style.SimplicityAccountThemeDark);
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_signin);
    editText1 = findViewById(R.id.email_edit);
    editText2 = findViewById(R.id.password_edit);
    verify = findViewById(R.id.verify_button);
    forgot = findViewById(R.id.forgot_pass);
    create = findViewById(R.id.create);
    toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        getSupportActionBar().setDisplayShowHomeEnabled(false);
        getSupportActionBar().setTitle(null);
    }

    AppCompatTextView copyright = findViewById(R.id.copy);
    copyright.setText("");
    try {
        create.setOnClickListener(v -> {
            Intent intent = new Intent(SimplicityAccount.this, NewSimplicityAccount.class);
            startActivity(intent);
            finish();

        });
        verify.setOnClickListener(v -> signIn(Objects.requireNonNull(editText1.getText()).toString(), Objects.requireNonNull(editText2.getText()).toString()));
        forgot.setOnClickListener(v -> resetPass(Objects.requireNonNull(editText1.getText()).toString()));
        editText2.setOnKeyListener((v, keyCode, event) -> {
            if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) {
                signIn(Objects.requireNonNull(editText1.getText()).toString(), Objects.requireNonNull(editText2.getText()).toString());
                return true;
            }
            return false;
        });
    }catch (NullPointerException i){
        i.printStackTrace();
    }catch (Exception ignored){

    }


}