List of usage examples for android.widget TextView TextView
public TextView(Context context)
From source file:Main.java
private static TextView createTextView(Context context, String text) { TextView textView = new TextView(context); textView.setText(text);//from w w w. j a va2 s . c o m return textView; }
From source file:Main.java
public static TextView createTextView(Context context, String text) { TextView tv = new TextView(context); tv.setPadding(10, 10, 10, 10);//from ww w . jav a 2 s . c om tv.setText(text); tv.setGravity(Gravity.CENTER); tv.setTextSize(24); tv.setTextColor(Color.RED); return tv; }
From source file:Main.java
private static void addText(Activity activity, String text, LinearLayout layout, int maxWidth) { TextView textView = new TextView(activity); textView.setTextSize(textSize);/* www.j a v a 2s . c o m*/ textView.setMaxWidth(maxWidth); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setText(text + " "); layout.addView(textView); }
From source file:Main.java
private static void addCount(Activity activity, Integer count, LinearLayout layout, String label) { if (count != null && count > 0) { TextView amt = new TextView(activity); amt.setTextSize(textSize);/*from ww w .java2s .c om*/ amt.setText(count.toString() + " " + label + " "); layout.addView(amt); } }
From source file:Main.java
protected static Bitmap creatCodeBitmap(String contents, int width, int height, Context context) { TextView tv = new TextView(context); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); tv.setLayoutParams(layoutParams);//from ww w.ja va2s .c o m tv.setText(contents); tv.setHeight(height); tv.setGravity(Gravity.CENTER_HORIZONTAL); tv.setWidth(width); tv.setDrawingCacheEnabled(true); tv.setTextColor(Color.BLACK); tv.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight()); tv.buildDrawingCache(); Bitmap bitmapCode = tv.getDrawingCache(); return bitmapCode; }
From source file:Main.java
public static String getDefaultFontSize(Context context) { String size = "15.0px"; TextView tv = new TextView(context); if (tv != null) { size = String.valueOf(tv.getTextSize()) + "px"; tv = null;/*from w w w. j av a 2s.co m*/ } return size; }
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);/* w ww.ja va 2 s . co m*/ dialogTitle.setPadding(10, 10, 10, 10); dialogTitle.setGravity(Gravity.CENTER); dialogTitle.setTextColor(Color.WHITE); dialogTitle.setTextSize(20); 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 void addSpacer(Activity activity, LinearLayout layout, String sp, int size) { TextView mSpacer = new TextView(activity); mSpacer.setTextSize(size);/* ww w.j av a 2s. c om*/ mSpacer.setText(sp); layout.addView(mSpacer); }
From source file:Main.java
public static String getDefaultFontWeight(Context context) { String style = "normal"; TextView tv = new TextView(context); if (tv != null) { Typeface tf = tv.getTypeface();// w ww . j a v a 2s . c o m if (tf != null && tf.isBold()) { style = "bold"; } } return style; }
From source file:Main.java
public static View getTestFragmentView(Activity activity, OnClickListener clickListener) { LinearLayout v = new LinearLayout(activity); v.setBackgroundColor(Color.BLUE); v.setOrientation(LinearLayout.VERTICAL); TextView tv1 = new TextView(activity); TextView tv2 = new TextView(activity); Button b1 = new Button(activity); Button b2 = new Button(activity); Button b3 = new Button(activity); b1.setText("reload 1"); b2.setText("reload 2"); b3.setText("reload all"); b1.setId(1);/*from w ww .ja v a 2 s . c o m*/ b2.setId(2); b3.setId(3); tv1.setId(android.R.id.text1); tv2.setId(android.R.id.text2); b1.setOnClickListener(clickListener); b2.setOnClickListener(clickListener); b3.setOnClickListener(clickListener); v.addView(tv1); v.addView(tv2); v.addView(b1); v.addView(b2); v.addView(b3); return v; }