List of usage examples for android.widget TextView setText
@android.view.RemotableViewMethod public final void setText(@StringRes int resid)
From source file:com.nextgis.maplibui.util.ControlHelper.java
public static void setZoomText(Activity activity, TextView text, int string, int zoom) { String scale = LocationUtil.formatLength(activity, MapUtil.getScaleInCm(activity, zoom), 0); text.setText(String.format(activity.getString(string) + "\r\n" + scale, zoom)); }
From source file:org.ligi.android.dubwise_uavtalk.dashboard.DownloadDashboardImagesStatusAlertDialog.java
/** * /*from w w w . j ava 2s.c o m*/ * @param activity * @param autoclose - if the alert should close when connection is established * */ public static void show(Context activity, boolean autoclose, Intent after_connection_intent) { LinearLayout lin = new LinearLayout(activity); lin.setOrientation(LinearLayout.VERTICAL); ScrollView sv = new ScrollView(activity); TextView details_text_view = new TextView(activity); LinearLayout lin_in_scrollview = new LinearLayout(activity); lin_in_scrollview.setOrientation(LinearLayout.VERTICAL); sv.addView(lin_in_scrollview); lin_in_scrollview.addView(details_text_view); details_text_view.setText("no text"); ProgressBar progress = new ProgressBar(activity, null, android.R.attr.progressBarStyleHorizontal); progress.setMax(img_lst.length); lin.addView(progress); lin.addView(sv); new AlertDialog.Builder(activity).setTitle("Download Status").setView(lin) .setPositiveButton("OK", new DialogDiscardingOnClickListener()).show(); class AlertDialogUpdater implements Runnable { private Handler h = new Handler(); private TextView myTextView; private ProgressBar myProgress; public AlertDialogUpdater(TextView ab, ProgressBar progress) { myTextView = ab; myProgress = progress; } public void run() { for (int i = 0; i < img_lst.length; i++) { class MsgUpdater implements Runnable { private int i; public MsgUpdater(int i) { this.i = i; } public void run() { myProgress.setProgress(i + 1); if (i != img_lst.length - 1) myTextView.setText("Downloading " + img_lst[i] + ".png"); else myTextView.setText("Ready - please restart DUBwise to apply changes!"); } } h.post(new MsgUpdater(i)); try { URLConnection ucon = new URL(url_lst[i]).openConnection(); BufferedInputStream bis = new BufferedInputStream(ucon.getInputStream()); ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; while ((current = bis.read()) != -1) baf.append((byte) current); File path = new File( Environment.getExternalStorageDirectory() + "/dubwise/images/dashboard"); path.mkdirs(); FileOutputStream fos = new FileOutputStream( new File(path.getAbsolutePath() + "/" + img_lst[i] + ".png")); fos.write(baf.toByteArray()); fos.close(); } catch (Exception e) { } try { Thread.sleep(199); } catch (InterruptedException e) { } } } } new Thread(new AlertDialogUpdater(details_text_view, progress)).start(); }
From source file:Main.java
public static void setTitle(TextView titleTv, int titleColor, int titleTextSize, int messageColor, int messageTextSize, CharSequence title, CharSequence message) { titleTv.setMinHeight(titleTextSize * 3); if (!TextUtils.isEmpty(title) && TextUtils.isEmpty(message)) { titleTv.setTextColor(titleColor); titleTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize); titleTv.getPaint().setFakeBoldText(true); titleTv.setText(title); } else if (TextUtils.isEmpty(title) && !TextUtils.isEmpty(message)) { titleTv.setTextColor(messageColor); titleTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, messageTextSize); titleTv.setText(message);/* w ww .ja v a 2s. co m*/ } else if (!TextUtils.isEmpty(title) && !TextUtils.isEmpty(message)) { SpannableString titleSs = new SpannableString(title + "\n" + message); titleSs.setSpan(new ForegroundColorSpan(titleColor), 0, title.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); titleSs.setSpan(new AbsoluteSizeSpan(titleTextSize), 0, title.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); titleSs.setSpan(new StyleSpan(Typeface.BOLD), 0, title.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); titleSs.setSpan(new ForegroundColorSpan(messageColor), title.length(), titleSs.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); titleSs.setSpan(new AbsoluteSizeSpan(messageTextSize), title.length(), titleSs.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); titleTv.setText(titleSs); titleTv.setLineSpacing(0.0f, 1.2f); } else { titleTv.setVisibility(View.GONE); } }
From source file:com.spoiledmilk.ibikecph.util.Util.java
public static void launchNoConnectionDialog(Context ctx) { final Dialog dialog = new Dialog(ctx); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_no_connection); TextView text = (TextView) dialog.findViewById(R.id.textNetworkError); text.setTypeface(IbikeApplication.getNormalFont()); text.setText(IbikeApplication.getString("network_error_text")); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.show();/*from w w w. ja va 2 s. c o m*/ final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { try { dialog.dismiss(); } catch (Exception e) { // dialog not attached to window } } }, 3000); }
From source file:com.evvsoft.treeview.SimpleJsonTreeViewAdapter.java
/** * Called by bindView() to set the text for a TextView but only if * there is no existing ViewBinder or if the existing ViewBinder cannot * handle binding to a TextView./*from w w w. ja v a 2 s . c o m*/ * * @param v TextView to receive text * @param text the text to be set for the TextView */ public static void setViewText(TextView v, String text) { v.setText(text); }
From source file:eu.e43.impeller.Utils.java
public static void updateStatebar(View parent, int replies, int likes, int shares) { TextView commentsIcon = (TextView) parent.findViewById(R.id.commentsIcon); TextView sharesIcon = (TextView) parent.findViewById(R.id.sharesIcon); TextView likesIcon = (TextView) parent.findViewById(R.id.likesIcon); commentsIcon.setTypeface(ImpellerApplication.fontAwesome); sharesIcon.setTypeface(ImpellerApplication.fontAwesome); likesIcon.setTypeface(ImpellerApplication.fontAwesome); TextView commentCount = (TextView) parent.findViewById(R.id.commentsCount); TextView shareCount = (TextView) parent.findViewById(R.id.sharesCount); TextView likeCount = (TextView) parent.findViewById(R.id.likesCount); commentCount.setText(String.valueOf(replies)); shareCount.setText(String.valueOf(shares)); likeCount.setText(String.valueOf(likes)); }
From source file:com.nextgis.mobile.map.LocalTMSLayer.java
protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName, int type, final Uri uri, final LocalTMSLayer layer) { final LinearLayout linearLayout = new LinearLayout(map.getContext()); final EditText input = new EditText(map.getContext()); input.setText(layerName);/*from ww w . jav a 2s .com*/ final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(map.getContext(), android.R.layout.simple_spinner_item); final Spinner spinner = new Spinner(map.getContext()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); adapter.add(map.getContext().getString(R.string.tmstype_qtiles)); adapter.add(map.getContext().getString(R.string.tmstype_osm)); adapter.add(map.getContext().getString(R.string.tmstype_normal)); adapter.add(map.getContext().getString(R.string.tmstype_ngw)); if (type == TMSTYPE_OSM) { spinner.setSelection(1); } else { spinner.setSelection(2); } final TextView stLayerName = new TextView(map.getContext()); stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":"); final TextView stLayerType = new TextView(map.getContext()); stLayerType.setText(map.getContext().getString(R.string.layer_type) + ":"); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(stLayerName); linearLayout.addView(input); linearLayout.addView(stLayerType); linearLayout.addView(spinner); new AlertDialog.Builder(map.getContext()) .setTitle(bCreate ? R.string.input_layer_properties : R.string.change_layer_properties) // .setMessage(message) .setView(linearLayout).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { int tmsType = 0; switch (spinner.getSelectedItemPosition()) { case 0: case 1: tmsType = TMSTYPE_OSM; break; case 2: case 3: tmsType = TMSTYPE_NORMAL; break; } if (bCreate) { create(map, input.getText().toString(), tmsType, uri); } else { layer.setName(input.getText().toString()); layer.setTMSType(tmsType); map.onLayerChanged(layer); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. Toast.makeText(map.getContext(), R.string.error_cancel_by_user, Toast.LENGTH_SHORT).show(); } }).show(); }
From source file:com.prasanna.android.stacknetwork.utils.MarkdownFormatter.java
private static TextView getTextView(Context context, LinearLayout.LayoutParams params, StringBuffer buffer) { TextView textView = new TextView(context); textView.setTextColor(Color.BLACK); textView.setLayoutParams(params);/*w w w. ja v a 2 s . c o m*/ textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setTextSize(getTextSize(context)); textView.setText(Html.fromHtml(buffer.toString())); return textView; }
From source file:Main.java
public static void readFromLog(int lines, TextView t) { File sdcard = new File(Environment.getExternalStorageDirectory() + "/clr_log.file"); //Read text from file StringBuilder text = new StringBuilder(); int n = 0;//from w ww . j a v a 2 s . co m try { BufferedReader br = new BufferedReader(new FileReader(sdcard)); String line; while ((line = br.readLine()) != null && n <= lines) { text.append(line); text.append('\n'); n++; } } catch (IOException e) { e.printStackTrace(); } //Set the text t.setText(text); }
From source file:com.hybris.mobile.app.commerce.helper.OrderHelper.java
public static void createDeliverySummary(Activity activity, Order order) { TextView mOrderConfirmDeliveryAddress; TextView mOrderConfirmDeliveryMode;/* w w w . j av a2s . c om*/ mOrderConfirmDeliveryAddress = (TextView) activity.findViewById(R.id.order_delivery_address_text); mOrderConfirmDeliveryMode = (TextView) activity.findViewById(R.id.order_delivery_method_text); if (order != null) { if (order.getDeliveryAddress() != null && StringUtils.isNotBlank(order.getDeliveryAddress().getFormattedAddress())) { mOrderConfirmDeliveryAddress.setText(order.getDeliveryAddress().getFormattedAddress()); } // Display delivery method if (order.getDeliveryMode() != null) { mOrderConfirmDeliveryMode.setText( order.getDeliveryMode().getName() + " - " + order.getDeliveryMode().getDescription() + " - " + order.getDeliveryMode().getDeliveryCost().getFormattedValue()); } } }