List of usage examples for android.widget TextView setText
@android.view.RemotableViewMethod public final void setText(@StringRes int resid)
From source file:com.smart.able2include.SimpleTextOverlayView.java
private void createView() { WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT);// ww w .ja va2 s . c o m params.gravity = Gravity.START | Gravity.TOP; params.x = 0; params.y = 30; params.width = wm.getDefaultDisplay().getWidth(); params.height = wm.getDefaultDisplay().getHeight() - 30; frameLayout = new RelativeLayout(mServiceContext); LayoutInflater layoutInflater = (LayoutInflater) mServiceContext .getSystemService(Context.LAYOUT_INFLATER_SERVICE); // Here is the place where you can inject whatever layout you want. layoutInflater.inflate(R.layout.simpletxt_layout, frameLayout); TextView text = (TextView) frameLayout.findViewById(R.id.textViewSimplifiedText); text.setText(mSimpleText); dialogButton = (Button) frameLayout.findViewById(R.id.simpleButtonOK); // if button is clicked, close the custom dialog dialogButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { RemoveOvelay(); delegate.onClick(); } }); synchronized (mSyncToken) { wm.addView(frameLayout, params); mOnTop = true; } }
From source file:com.spotify.sdk.android.authentication.sample.MainActivity.java
private void updateCodeView() { final TextView codeView = (TextView) findViewById(R.id.code_text_view); codeView.setText(getString(R.string.code, mAccessCode)); }
From source file:com.facebook.notifications.internal.content.TextContent.java
@Override public void applyTo(@NonNull View view) { if (view instanceof TextView) { TextView textView = (TextView) view; textView.setText(getText()); textView.setTextColor(getTextColor()); Typeface typeface = FontUtilities.parseFont(getTypeface()); typeface = typeface != null ? typeface : Typeface.DEFAULT; textView.setTypeface(typeface);// w ww . j ava 2 s. c o m textView.setTextSize(getTypefaceSize()); switch (getTextAlignment()) { case Left: textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); break; case Center: textView.setGravity(Gravity.CENTER); break; case Right: textView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); break; } } }
From source file:com.spotify.sdk.android.authentication.sample.MainActivity.java
private void updateTokenView() { final TextView tokenView = (TextView) findViewById(R.id.token_text_view); tokenView.setText(getString(R.string.token, mAccessToken)); }
From source file:com.vrem.wifianalyzer.wifi.accesspoint.AccessPointDetail.java
private void setViewCompact(@NonNull Context context, @NonNull View view, @NonNull WiFiDetail wiFiDetail, boolean isChild) { ((TextView) view.findViewById(R.id.ssid)).setText(wiFiDetail.getTitle()); WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal(); Strength strength = wiFiSignal.getStrength(); Security security = wiFiDetail.getSecurity(); ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage); securityImage.setImageResource(security.getImageResource()); securityImage.setColorFilter(ContextCompat.getColor(context, R.color.icons_color)); TextView textLevel = (TextView) view.findViewById(R.id.level); textLevel.setText(String.format(Locale.ENGLISH, "%ddBm", wiFiSignal.getLevel())); textLevel.setTextColor(ContextCompat.getColor(context, strength.colorResource())); ((TextView) view.findViewById(R.id.channel)).setText(wiFiSignal.getChannelDisplay()); ((TextView) view.findViewById(R.id.primaryFrequency)).setText(String.format(Locale.ENGLISH, "%d%s", wiFiSignal.getPrimaryFrequency(), WiFiSignal.FREQUENCY_UNITS)); ((TextView) view.findViewById(R.id.distance)) .setText(String.format(Locale.ENGLISH, "%5.1fm", wiFiSignal.getDistance())); if (isChild) { view.findViewById(R.id.tab).setVisibility(View.VISIBLE); } else {/*from w w w .j a v a 2 s . co m*/ view.findViewById(R.id.tab).setVisibility(View.GONE); } }
From source file:com.amanmehara.programming.android.activities.DetailActivity.java
private void setProgramName(int id, JSONObject program) { TextView name = (TextView) findViewById(id); try {//from w w w . j av a2 s . c o m name.setText(program.getString("name")); } catch (JSONException e) { Log.e(TAG, e.getMessage()); } }
From source file:com.sawyer.advadapters.app.dialogs.AddJSONArrayDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.setContentView(R.layout.dialog_add_jsonarray); dialog.setTitle(R.string.title_dialog_add_movies); Button btn = (Button) dialog.findViewById(R.id.movie_single_btn); btn.setOnClickListener(new OnAddSingleClickListener()); TextView tv = (TextView) dialog.findViewById(R.id.movie_single_txt); tv.setText("- " + mMovieItems.optJSONObject(0).optString(MovieItem.JSON_TITLE)); btn = (Button) dialog.findViewById(R.id.movies_jsonarray_btn); btn.setOnClickListener(new OnAddJSONArrayClickListener()); tv = (TextView) dialog.findViewById(R.id.movie_multi_txt1); tv.setText("- " + mMovieItems.optJSONObject(1).optString(MovieItem.JSON_TITLE)); tv = (TextView) dialog.findViewById(R.id.movie_multi_txt2); tv.setText("- " + mMovieItems.optJSONObject(2).optString(MovieItem.JSON_TITLE)); btn = (Button) dialog.findViewById(R.id.movies_vararg_btn); btn.setOnClickListener(new OnAddVarargsClickListener()); btn.setVisibility(mIsArgvargsEnabled ? View.VISIBLE : View.GONE); return dialog; }
From source file:com.aqnote.app.wifianalyzer.wifi.AccessPointsDetail.java
void setView(@NonNull Resources resources, @NonNull View view, @NonNull WiFiDetail wiFiDetail, boolean isChild) { TextView textSSID = (TextView) view.findViewById(R.id.ssid); textSSID.setText(wiFiDetail.getTitle()); view.findViewById(R.id.ipAddress).setVisibility(View.GONE); view.findViewById(R.id.linkSpeed).setVisibility(View.GONE); ImageView configuredImage = (ImageView) view.findViewById(R.id.configuredImage); WiFiAdditional wiFiAdditional = wiFiDetail.getWiFiAdditional(); if (wiFiAdditional.isConfiguredNetwork()) { configuredImage.setVisibility(View.VISIBLE); configuredImage.setColorFilter(resources.getColor(R.color.connected)); } else {//from w ww .j a v a 2 s . com configuredImage.setVisibility(View.GONE); } WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal(); Strength strength = wiFiSignal.getStrength(); ImageView imageView = (ImageView) view.findViewById(R.id.levelImage); imageView.setImageResource(strength.imageResource()); imageView.setColorFilter(resources.getColor(strength.colorResource())); Security security = wiFiDetail.getSecurity(); ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage); securityImage.setImageResource(security.imageResource()); securityImage.setColorFilter(resources.getColor(R.color.icons_color)); TextView textLevel = (TextView) view.findViewById(R.id.level); textLevel.setText(wiFiSignal.getLevel() + "dBm"); textLevel.setTextColor(resources.getColor(strength.colorResource())); ((TextView) view.findViewById(R.id.channel)).setText(wiFiSignal.getChannelDisplay()); ((TextView) view.findViewById(R.id.primaryFrequency)) .setText(wiFiSignal.getPrimaryFrequency() + WifiInfo.FREQUENCY_UNITS); ((TextView) view.findViewById(R.id.distance)).setText(String.format("%.1fm", wiFiSignal.getDistance())); ((TextView) view.findViewById(R.id.channel_frequency_range)) .setText(wiFiSignal.getFrequencyStart() + " - " + wiFiSignal.getFrequencyEnd()); ((TextView) view.findViewById(R.id.width)) .setText("(" + wiFiSignal.getWiFiWidth().getFrequencyWidth() + WifiInfo.FREQUENCY_UNITS + ")"); ((TextView) view.findViewById(R.id.capabilities)).setText(wiFiDetail.getCapabilities()); TextView textVendor = ((TextView) view.findViewById(R.id.vendor)); String vendor = wiFiAdditional.getVendorName(); if (StringUtils.isBlank(vendor)) { textVendor.setVisibility(View.GONE); } else { textVendor.setVisibility(View.VISIBLE); textVendor.setText(vendor.substring(0, Math.min(VENDOR_NAME_MAX, vendor.length()))); } if (isChild) { view.findViewById(R.id.tab).setVisibility(View.VISIBLE); } else { view.findViewById(R.id.tab).setVisibility(View.GONE); } }
From source file:com.vrem.wifianalyzer.wifi.AccessPointDetail.java
private void setViewCompact(@NonNull Context context, @NonNull View view, @NonNull WiFiDetail wiFiDetail, boolean isChild) { ((TextView) view.findViewById(R.id.ssid)).setText(wiFiDetail.getTitle()); WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal(); Strength strength = wiFiSignal.getStrength(); Security security = wiFiDetail.getSecurity(); ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage); securityImage.setImageResource(security.imageResource()); securityImage.setColorFilter(ContextCompat.getColor(context, R.color.icons_color)); TextView textLevel = (TextView) view.findViewById(R.id.level); textLevel.setText(String.format(Locale.ENGLISH, "%ddBm", wiFiSignal.getLevel())); textLevel.setTextColor(ContextCompat.getColor(context, strength.colorResource())); //SET CHANNEL ((TextView) view.findViewById(R.id.channel)).setText(wiFiSignal.getChannelDisplay()); ((TextView) view.findViewById(R.id.primaryFrequency)).setText(String.format(Locale.ENGLISH, "%d%s", wiFiSignal.getPrimaryFrequency(), WiFiSignal.FREQUENCY_UNITS)); ((TextView) view.findViewById(R.id.distance)) .setText(String.format(Locale.ENGLISH, "%5.1fm", wiFiSignal.getDistance())); if (isChild) { view.findViewById(R.id.tab).setVisibility(View.VISIBLE); } else {//w w w . j av a2s . c o m view.findViewById(R.id.tab).setVisibility(View.GONE); } }
From source file:org.npr.android.news.StationListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { View line = super.getView(position, convertView, parent); Station station = getItem(position); TextView name = (TextView) line.findViewById(R.id.StationItemNameText); name.setText(Html.fromHtml(station.getName())); TextView location = (TextView) line.findViewById(R.id.StationItemLocationText); location.setText(Html.fromHtml(station.getMarketCity())); TextView frequency = (TextView) line.findViewById(R.id.StationItemFrequencyText); if (station.getFrequency() != null && station.getBand() != null) { frequency.setText(Html.fromHtml(String.format("%s %s", station.getFrequency(), station.getBand()))); } else {//w w w . j av a 2 s .c o m frequency.setText(""); } if (favoriteStationsRepository != null) { TextView preset = (TextView) line.findViewById(R.id.StationPresetView); FavoriteStationEntry favoriteStationEntry = favoriteStationsRepository .getFavoriteStationForStationId(station.getId()); if (favoriteStationEntry != null && favoriteStationEntry.preset != null) { preset.setText(favoriteStationEntry.preset); preset.setVisibility(View.VISIBLE); } else { preset.setVisibility(View.INVISIBLE); } } return line; }