List of usage examples for android.widget TextView setText
@android.view.RemotableViewMethod public final void setText(@StringRes int resid)
From source file:Main.java
public static void setTextInView(int viewId, String val, Activity activity) { TextView textView = (TextView) activity.findViewById(viewId); if (textView != null) textView.setText(val); }
From source file:Main.java
public static void setTextViewEx(Map<String, Object> m, TextView v, String key, String format) { String s = toString(m.get(key)); v.setText(String.format(format, s)); }
From source file:Main.java
public static void showOkDialog(String title, String msg, Activity act) { AlertDialog.Builder dialog = new AlertDialog.Builder(act); if (title != null) { TextView dialogTitle = new TextView(act); dialogTitle.setText(title); dialogTitle.setPadding(10, 10, 10, 10); dialogTitle.setGravity(Gravity.CENTER); dialogTitle.setTextColor(Color.WHITE); dialogTitle.setTextSize(20);/* www . java 2 s .c o m*/ dialog.setCustomTitle(dialogTitle); } if (msg != null) { dialog.setMessage(msg); } dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub dialog.dismiss(); } }); AlertDialog dlg = dialog.show(); TextView messageText = (TextView) dlg.findViewById(android.R.id.message); messageText.setGravity(Gravity.CENTER); }
From source file:Main.java
public static TextView setText(Activity activity, int resourceId, String text) { TextView tv = (TextView) activity.findViewById(resourceId); if (text != null) { tv.setText(text); }/*from w w w . j a v a 2 s . c o m*/ return tv; }
From source file:Main.java
public static boolean setText(View view, int resid, String text) { TextView mTextView = (TextView) view.findViewById(resid); if (mTextView != null) { mTextView.setText(text); return true; }//from ww w.j a v a 2 s. com return false; }
From source file:Main.java
public static boolean setText(TextView textView, String string) { if (textView == null) return false; textView.setText(TextUtils.isEmpty(string) ? "" : string); return true;// w w w . j a va 2 s . c o m }
From source file:Main.java
public static void showTextNormal(TextView tv, String text) { if ((null == tv) || (null == text)) { return;//www. j a va 2 s . co m } tv.setText(text); }
From source file:Main.java
public static void setValue(TextView v, int resid) { String titls = v.getResources().getString(resid); v.setText(titls); }
From source file:Main.java
public static void jsonToAndroidLayoutMapper(Class<?> classObj, JSONObject json, String prefixStr, Activity view) throws JSONException { for (int i = 0; i < json.names().length(); i++) { String keyStr = (String) json.names().get(i); Field fieldObj = null;/*from ww w . j a va2 s. co m*/ try { fieldObj = classObj.getField(prefixStr + "_" + keyStr.toLowerCase()); } catch (NoSuchFieldException e) { continue; } Object layoutObj = null; try { layoutObj = fieldObj.get(fieldObj); } catch (IllegalAccessException e) { continue; } Integer layoutIntvalue = (Integer) layoutObj; View selectedView = view.findViewById(layoutIntvalue); if (selectedView instanceof TextView) { TextView textView = (TextView) selectedView; textView.setText((String) json.get(keyStr)); } else if (selectedView instanceof ImageView) { ImageView imageView = (ImageView) selectedView; } } }
From source file:Main.java
/** * Populate the given {@link TextView} with the requested text, formatting * through {@link Html#fromHtml(String)} when applicable. Also sets * {@link TextView#setMovementMethod} so inline links are handled. */// ww w .j av a 2 s . c om public static void setTextMaybeHtml(TextView view, String text) { if (TextUtils.isEmpty(text)) { view.setText(""); return; } if (text.contains("<") && text.contains(">")) { view.setText(Html.fromHtml(text)); view.setMovementMethod(LinkMovementMethod.getInstance()); } else { view.setText(text); } }