Java Code Examples for android.support.v7.widget.AppCompatTextView#setText()
The following examples show how to use
android.support.v7.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: BaseActivity.java From africastalking-android with MIT License | 6 votes |
protected void showInfo(String header, String desc, @Nullable Drawable drawable, boolean error) { hideKeyboard(); AppCompatTextView infoHeader = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_header); AppCompatTextView infoDesc = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_desc); AppCompatImageView infoImg = (AppCompatImageView) llBottomSheet.findViewById(R.id.info_img); if (error) { llBottomSheet.findViewById(R.id.info_img).setVisibility(View.GONE); ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Close"); } else { llBottomSheet.findViewById(R.id.info_img).setVisibility(View.VISIBLE); ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Ok"); } infoHeader.setText(header); infoDesc.setText(desc); if (drawable != null) infoImg.setImageDrawable(drawable); bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); }
Example 2
Source File: Luhn.java From Luhn with MIT License | 6 votes |
private void showInfo(String header, String desc, @Nullable Drawable drawable, boolean error) { hideKeyboard(); AppCompatTextView infoHeader = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_header); AppCompatTextView infoDesc = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_desc); AppCompatImageView infoImg = (AppCompatImageView) llBottomSheet.findViewById(R.id.info_img); if (error) { llBottomSheet.findViewById(R.id.info_img).setVisibility(View.GONE); ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Close"); } else { llBottomSheet.findViewById(R.id.info_img).setVisibility(View.VISIBLE); ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Ok"); } infoHeader.setText(header); infoDesc.setText(desc); if (drawable != null) infoImg.setImageDrawable(drawable); bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); }
Example 3
Source File: ActivityUtils.java From memetastic with GNU General Public License v3.0 | 6 votes |
public void showDialogWithHtmlTextView(@StringRes int resTitleId, String text, boolean isHtml, DialogInterface.OnDismissListener dismissedListener) { ScrollView scroll = new ScrollView(_context); AppCompatTextView textView = new AppCompatTextView(_context); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, _context.getResources().getDisplayMetrics()); scroll.setPadding(padding, 0, padding, 0); scroll.addView(textView); textView.setMovementMethod(new LinkMovementMethod()); textView.setText(isHtml ? new SpannableString(Html.fromHtml(text)) : text); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17); AlertDialog.Builder dialog = new AlertDialog.Builder(_context) .setPositiveButton(android.R.string.ok, null).setOnDismissListener(dismissedListener) .setView(scroll); if (resTitleId != 0) { dialog.setTitle(resTitleId); } dialogFullWidth(dialog.show(), true, false); }
Example 4
Source File: ActivityUtils.java From openlauncher with Apache License 2.0 | 6 votes |
public void showDialogWithHtmlTextView(@StringRes int resTitleId, String text, boolean isHtml, DialogInterface.OnDismissListener dismissedListener) { ScrollView scroll = new ScrollView(_context); AppCompatTextView textView = new AppCompatTextView(_context); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, _context.getResources().getDisplayMetrics()); scroll.setPadding(padding, 0, padding, 0); scroll.addView(textView); textView.setMovementMethod(new LinkMovementMethod()); textView.setText(isHtml ? new SpannableString(Html.fromHtml(text)) : text); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17); AlertDialog.Builder dialog = new AlertDialog.Builder(_context) .setPositiveButton(android.R.string.ok, null).setOnDismissListener(dismissedListener) .setView(scroll); if (resTitleId != 0) { dialog.setTitle(resTitleId); } dialogFullWidth(dialog.show(), true, false); }
Example 5
Source File: PhotoLayout.java From nono-android with GNU General Public License v3.0 | 6 votes |
private void initPreContainer(){ preContainer=new LinearLayout(getContext()); preContainer.setOrientation(LinearLayout.HORIZONTAL); LayoutParams lp=new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp.gravity=Gravity.CENTER_VERTICAL; preContainer.setLayoutParams(lp); preContainer.setOnClickListener(this); AppCompatImageView tmpImageView=new AppCompatImageView(getContext()); tmpImageView.setBackgroundResource(R.mipmap.ic_image_black_24dp); AppCompatTextView tmpTextView=new AppCompatTextView(getContext()); LinearLayout.LayoutParams lp1=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp1.gravity=Gravity.CENTER_VERTICAL; tmpImageView.setLayoutParams(lp1); tmpTextView.setLayoutParams(lp1); tmpTextView.setText(getContext().getString(R.string.select_photo)); preContainer.addView(tmpImageView); preContainer.addView(tmpTextView); this.addView(preContainer); }
Example 6
Source File: DotLayout.java From nono-android with GNU General Public License v3.0 | 6 votes |
@Override protected void initUI() { LinearLayout linearLayout=new LinearLayout(getContext()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); textView=new AppCompatTextView(getContext()); int size=(int)(getResources().getDisplayMetrics().density*32); LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(size,size); //lp.gravity=Gravity.CENTER_VERTICAL; textView.setLayoutParams(lp); textView.setText("·"); textView.setTextColor(0xff000000); textView.setTextAppearance(getContext(),R.style.DotTextAppearance); textView.setGravity(Gravity.CENTER); editText=new BaseRichEditText(getContext()); editText.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT,1.0f)); linearLayout.addView(textView); linearLayout.addView(editText); this.addView(linearLayout); }
Example 7
Source File: BaseBottomDelegate.java From FastWaiMai with MIT License | 5 votes |
@Override public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View view) { final int size = ITEMS.size(); for(int i = 0; i < size; i++){ LayoutInflater.from(getContext()).inflate(R.layout.bottom_item_icon_text_layout, mBottomBar); final RelativeLayout item = (RelativeLayout) mBottomBar.getChildAt(i); //设置每一个item的点击事件 item.setTag(i); item.setOnClickListener(this); //图标 final IconTextView itemIcon = (IconTextView) item.getChildAt(0); //文字 final AppCompatTextView itemTitle = (AppCompatTextView) item.getChildAt(1); final BottomTabBean bean = TAB_BEANS.get(i); //初始化数据 itemIcon.setText(bean.getIcon()); itemTitle.setText(bean.getTitle()); if (i == mIndexDelegate) { itemIcon.setTextColor(mClickedColor); itemTitle.setTextColor(mClickedColor); } } final ISupportFragment[] delegateArray = ITEM_DELEGATES.toArray(new ISupportFragment[size]); //加载多个同级根Fragment,类似Wechat, QQ主页的场景 getSupportDelegate().loadMultipleRootFragment(R.id.bottom_bar_delegate_container, mIndexDelegate, delegateArray); }
Example 8
Source File: CallRecyclerViewAdapter.java From PowerSwitch_Android with GNU General Public License v3.0 | 5 votes |
@Override public void onBindViewHolder(final CallRecyclerViewAdapter.ViewHolder holder, int position) { final CallEvent callEvent = callEvents.get(holder.getAdapterPosition()); String phoneNumbers = ""; Iterator<String> iterator = callEvent.getPhoneNumbers(PhoneConstants.Type.INCOMING).iterator(); while (iterator.hasNext()) { phoneNumbers += iterator.next(); if (iterator.hasNext()) { phoneNumbers += "\n"; } } holder.phoneNumbers.setText(phoneNumbers); for (Action action : callEvent.getActions(PhoneConstants.Type.INCOMING)) { AppCompatTextView textViewActionDescription = new AppCompatTextView(context); textViewActionDescription.setText(action.toString()); textViewActionDescription.setPadding(0, 0, 0, 4); holder.linearLayoutActions.addView(textViewActionDescription); } if (holder.getAdapterPosition() == getItemCount() - 1) { holder.footer.setVisibility(View.VISIBLE); } else { holder.footer.setVisibility(View.GONE); } }
Example 9
Source File: Term.java From Ansole with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("ResourceType") @Override public View getView(int position, View convertView, ViewGroup parent) { AppCompatTextView label = (AppCompatTextView) LayoutInflater.from(Term.this).inflate(R.layout.window_list_item_actionbar, null, false); String title = getSessionTitle(position, getString(R.string.window_title, position + 1)); label.setText(title); return label; }
Example 10
Source File: ProfileFragment.java From citrus with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // Count of uncompleted tasks AppCompatTextView uncompletedTaskCount = findById(view, R.id.profile_uncompleted_count_text); long uncompletedCount = TaskRepository.countByCompleted(mUIThreadRealm, false); uncompletedTaskCount.setText(String.valueOf(uncompletedCount)); // Count of completed tasks AppCompatTextView completedTaskCount = findById(view, R.id.profile_completed_count_text); long completedCount = TaskRepository.countByCompleted(mUIThreadRealm, true); completedTaskCount.setText(String.valueOf(completedCount)); // Count of all tasks AppCompatTextView allTaskCount = findById(view, R.id.profile_all_count_text); long allCount = TaskRepository.count(mUIThreadRealm); allTaskCount.setText(String.valueOf(allCount)); // Description about state of task AppCompatTextView state = findById(view, R.id.profile_state_text); String stateStr; if (completedCount < uncompletedCount) { stateStr = getString(R.string.you_can_do_it); } else if (completedCount > uncompletedCount) { stateStr = getString(R.string.good_job); } else { stateStr = getString(R.string.keep_it_up); } state.setText(stateStr); }
Example 11
Source File: SettingsSpinnerAdapter.java From Puff-Android with MIT License | 5 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { AppCompatTextView ret = new AppCompatTextView(parent.getContext()); ret.setText(displayText[position]); ret.setTextSize(16); ret.setPadding(0, 10, 0, 10); ret.setTextColor(Color.BLACK); return ret; }
Example 12
Source File: ActivityUtils.java From kimai-android with MIT License | 5 votes |
public void showDialogWithHtmlTextView(@StringRes int resTitleId, String text, boolean isHtml, DialogInterface.OnDismissListener dismissedListener) { ScrollView scroll = new ScrollView(_context); AppCompatTextView textView = new AppCompatTextView(_context); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, _context.getResources().getDisplayMetrics()); scroll.setPadding(padding, 0, padding, 0); scroll.addView(textView); textView.setMovementMethod(new LinkMovementMethod()); textView.setText(isHtml ? new SpannableString(Html.fromHtml(text)) : text); AlertDialog.Builder dialog = new AlertDialog.Builder(_context) .setPositiveButton(android.R.string.ok, null).setOnDismissListener(dismissedListener) .setTitle(resTitleId).setView(scroll); dialog.show(); }
Example 13
Source File: ViewActivity.java From RichEditor with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_view); // Intent intent = getIntent(); // CharSequence charSequence = intent.getParcelableExtra(TEXT); AppCompatTextView textView = (AppCompatTextView) findViewById(R.id.text); textView.setText(MainActivity.text); textView.setMovementMethod(LinkMovementMethod.getInstance()); }
Example 14
Source File: ProfileActivity.java From DelegateAdapter with Apache License 2.0 | 5 votes |
private void showCount (View countView, int count, int title) { AppCompatTextView top = countView.findViewById(R.id.vertical_text_top); AppCompatTextView bottom = countView.findViewById(R.id.vertical_text_bottom); top.setText(count + ""); bottom.setText(title); }
Example 15
Source File: OrderListAdapter.java From FastWaiMai with MIT License | 5 votes |
@Override protected void convert(BaseViewHolder helper, MultipleItemEntity item) { switch (helper.getItemViewType()){ case OrderListItemType.ITEM_ORDER_LIST_HEADER: //订单ID String orderId = item.getField(OrderItemFields.ORDER_ID); //创建时间 String createTime = item.getField(OrderItemFields.CREATE_TIME); //订单状态 String orderStatus = item.getField(OrderItemFields.PAY_STATE); final AppCompatTextView orderIdView = helper.getView(R.id.tv_item_allorder_orderid); helper.setText(R.id.tv_item_allorder_state, orderStatus); //helper.setText(R.id.tv_item_allorder_createtime, createTime); orderIdView.setText(String.valueOf("订单编号:"+orderId)); break; case OrderListItemType.ITEM_ORDER_LIST_CONTENT: final String goodsName = item.getField(OrderItemFields.PRODUCT_NAME); final String goodsPic = item.getField(OrderItemFields.PRODUCT_IMG); final double goodsPrice = item.getField(OrderItemFields.PRODUCT_PRICE); final int count = item.getField(OrderItemFields.PRODUCT_COUNT); helper.setText(R.id.tv_item_allorder_title, goodsName); helper.setText(R.id.tv_item_allorder_item_num, "共"+count+"件"); helper.setText(R.id.tv_item_allorder_item_price, goodsPrice+""); final AppCompatImageView imgThumb = helper.getView(R.id.iv_item_allorder_pic); Glide.with(mContext) .load(goodsPic) .apply(OPTIONS) .into(imgThumb); break; case OrderListItemType.ITEM_ORDER_LIST_FOOTER: final Double totalPrice = item.getField(OrderItemFields.TOTAL_PRICE); helper.setText(R.id.tv_item_allorder_total, totalPrice+""); break; default: break; } }
Example 16
Source File: SetQuickPasswordActivity.java From Puff-Android with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_set_quick_password); EventBus.getDefault().register(this); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); hintStrSet = getString(R.string.set_gesture_password); hintStrVerify = getString(R.string.verify_gesture_password); patternView = (PatternView) findViewById(R.id.lock_view); hintTextView = (AppCompatTextView) findViewById(R.id.hint_view); type = getIntent().getLongExtra("type", ShowTypeSet); // findViewById(R.id.content_setpassword).getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { // @Override // public boolean onPreDraw() { // // Blurry.with(SetQuickPasswordActivity.this) // .radius(0) // .sampling(2) // .onto((ViewGroup) findViewById(R.id.content_setpassword)); // return true; // } // }); patternView.setOnPatternDetectedListener(new PatternView.OnPatternDetectedListener() { @Override public void onPatternDetected() { quickCode = patternView.getPatternString(); if (type == ShowTypeVerify) { checkQuickPass(); } } }); if (type == ShowTypeVerify) { masterPassword = getIntent().getStringExtra("masterPassword"); fab.setVisibility(View.INVISIBLE); hintTextView.setText(hintStrVerify); } else { fab.setVisibility(View.VISIBLE); hintTextView.setText(hintStrSet); } fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!validateInput()) return; startActivity(new Intent(SetQuickPasswordActivity.this, AuthorizeActivity.class)); } }); }
Example 17
Source File: AboutFragment.java From ESeal with Apache License 2.0 | 4 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_about, container, false); aboutContent = view.findViewById(R.id.about_content); webContent = view.findViewById(R.id.web_content); webView = (WebView) view.findViewById(R.id.webView); progressBar = (ContentLoadingProgressBar) view.findViewById(R.id.progress); webErrorContent = view.findViewById(R.id.web_error_content); appVersionName = (AppCompatTextView) view.findViewById(R.id.app_version_name); appNewVersionHint = (AppCompatTextView) view.findViewById(R.id.app_new_version_hint); appNewVersionName = (AppCompatTextView) view.findViewById(R.id.app_new_version_name); String versionName = VersionHelper.getVersionName(getContext()); appVersionName.setText(versionName); view.findViewById(R.id.update_version_area).setOnClickListener(__ -> mPresenter.checkUpdateVersion(false)); view.findViewById(R.id.app_introduction).setOnClickListener(__ -> showIntroduction()); view.findViewById(R.id.app_thanks).setOnClickListener(__ -> showThanks()); view.findViewById(R.id.app_about_me).setOnClickListener(__ -> showAboutMe()); toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar); toolbar.setNavigationOnClickListener(__ -> { if (webContent.getVisibility() == View.VISIBLE) { webContent.setVisibility(View.GONE); aboutContent.setVisibility(View.VISIBLE); toolbar.setTitle(R.string.about); } else if (webContent.getVisibility() == View.GONE) { getActivity().onBackPressed(); } }); setupWebView(); return view; }
Example 18
Source File: ConfettiCellBuilder.java From oneHookLibraryAndroid with Apache License 2.0 | 4 votes |
@Nullable public View emojiCell(@StringRes final int stringRes) { final AppCompatTextView tv = new AppCompatTextView(mContext); tv.setText(stringRes); return tv; }
Example 19
Source File: ConfigureReceiverDialogPage4TabbedSummaryFragment.java From PowerSwitch_Android with GNU General Public License v3.0 | 4 votes |
private void updateUiValues() { name.setText(currentName); roomName.setText(currentRoomName); if (currentBrand == null) { brand.setText(""); } else { brand.setText(currentBrand.toString()); } model.setText(currentModel); channelMaster.setText(String.valueOf(currentMaster)); channelSlave.setText(String.valueOf(currentSlave)); String inflaterString = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(inflaterString); if (currentDips != null) { linearLayoutDips.removeAllViews(); for (DipSwitch dipSwitch : currentDips) { @SuppressLint("InflateParams") SwitchCompat switchCompat = (SwitchCompat) inflater.inflate(R.layout.default_switch_compat, null, false); switchCompat.setText(dipSwitch.getName()); switchCompat.setChecked(dipSwitch.isChecked()); switchCompat.setClickable(false); linearLayoutDips.addView(switchCompat, new LinearLayout.LayoutParams(LinearLayout.LayoutParams .WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); } } seed.setText(String.valueOf(currentSeed)); if (currentUniversalButtons != null) { linearLayoutUniversalButtons.removeAllViews(); for (Button button : currentUniversalButtons) { UniversalButton universalButton = (UniversalButton) button; LinearLayout linearLayout = new LinearLayout(getActivity()); AppCompatTextView textView = new AppCompatTextView(getActivity()); textView.setText("Name: " + universalButton.getName() + "\n" + "Signal: " + universalButton.getSignal()); linearLayout.addView(textView); linearLayoutUniversalButtons.addView(linearLayout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); } } }
Example 20
Source File: FeedSpinnerAdapter.java From AndroidApp with GNU Affero General Public License v3.0 | 4 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { AppCompatTextView checkedTextView = (AppCompatTextView) super.getView(position, convertView, parent); checkedTextView.setText(feedNames.get(position)); return checkedTextView; }