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 setPartialSizeAndColor(TextView tv, int start, int end, int textSize, int textColor) { String s = tv.getText().toString(); Spannable spannable = new SpannableString(s); spannable.setSpan(new AbsoluteSizeSpan(textSize, false), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spannable.setSpan(new ForegroundColorSpan(textColor), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); tv.setText(spannable); }
From source file:org.youaretheone.website.client.UoneSearchGsonActivity.java
private static View createTabView(final Context context, final String text, int iconResource) { View view = LayoutInflater.from(context).inflate(R.layout.tabs_layout, null); TextView tv = (TextView) view.findViewById(R.id.tabsText); tv.setText(text); ImageView icon = (ImageView) view.findViewById(R.id.tabsIcon); icon.setImageResource(iconResource); return view;/* www . j a v a 2s.com*/ }
From source file:com.nextgis.mobile.map.RemoteTMSLayer.java
protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName, String layerUrl, int type, final RemoteTMSLayer layer) { final LinearLayout linearLayout = new LinearLayout(map.getContext()); final EditText input = new EditText(map.getContext()); input.setText(layerName);// w w w . j ava 2s .c o m final EditText url = new EditText(map.getContext()); url.setText(layerUrl); final TextView stLayerName = new TextView(map.getContext()); stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":"); final TextView stLayerUrl = new TextView(map.getContext()); stLayerUrl.setText(map.getContext().getString(R.string.layer_url) + ":"); final TextView stLayerType = new TextView(map.getContext()); stLayerType.setText(map.getContext().getString(R.string.layer_type) + ":"); 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_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(0); } else { spinner.setSelection(1); } linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(stLayerName); linearLayout.addView(input); linearLayout.addView(stLayerUrl); linearLayout.addView(url); 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(), url.getText().toString(), tmsType); } 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.nagopy.android.xposed.utilities.ModBrightness.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @XMinSdkVersion(Build.VERSION_CODES.JELLY_BEAN_MR1) @HandleInitPackageResources(targetPackage = XConst.PKG_SYSTEM_UI, summary = "??") public static void brightnessDebugger(final String modulePath, final InitPackageResourcesParam resparam, final ModBrightnessSettingsGen settings) throws Throwable { if (!settings.brightnessDebugger) { return;// ww w .j av a 2s . c om } resparam.res.hookLayout(XConst.PKG_SYSTEM_UI, "layout", "super_status_bar", new XC_LayoutInflated() { @Override public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable { LinearLayout parent = (LinearLayout) liparam.view .findViewById(liparam.res.getIdentifier("system_icon_area", "id", XConst.PKG_SYSTEM_UI)); // ? TextView luxTextView = new TextView(parent.getContext()); luxTextView.setTextSize(8); luxTextView.setSingleLine(false); luxTextView.setTextColor(Color.WHITE); luxTextView.setText(""); parent.setGravity(Gravity.CENTER_VERTICAL); parent.addView(luxTextView, 0); AutoBrightnessController autoBrightnessChangedReceiver = new AutoBrightnessController(luxTextView); IntentFilter intentFilter = new IntentFilter( AutoBrightnessController.ACTION_AUTO_BRIGHTNESS_CHANGED); intentFilter.addAction(Intent.ACTION_SCREEN_OFF); parent.getContext().registerReceiver(autoBrightnessChangedReceiver, intentFilter); } }); }
From source file:com.jamesgiang.aussnowcam.Utils.java
public static void About(Context c) { AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(c); dialogBuilder.setTitle(R.string.app_name); dialogBuilder.setIcon(R.drawable.icon); TextView textView = new TextView(c); SpannableString s = new SpannableString(c.getString(R.string.about_info)); Linkify.addLinks(s, Linkify.WEB_URLS); textView.setText(s); textView.setGravity(Gravity.CENTER); textView.setMovementMethod(LinkMovementMethod.getInstance()); dialogBuilder.setView(textView);//w w w .j av a 2 s . co m dialogBuilder.show(); }
From source file:com.memetro.android.alerts.CommentDialog.java
public static void showDialog(final Context context, String comment, String creator, boolean isMine, final Long id) { final Dialog mDialog = new Dialog(context); mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); mDialog.setContentView(R.layout.comment_dialog); mDialog.setCancelable(true);//ww w . j a va2 s . c om TextView titleText = (TextView) mDialog.findViewById(R.id.title); TextView messageText = (TextView) mDialog.findViewById(R.id.message); Button closeButton = (Button) mDialog.findViewById(R.id.close); Button deleteButton = (Button) mDialog.findViewById(R.id.delete); titleText.setText(titleText.getText().toString() + " " + creator); messageText.setMovementMethod(ScrollingMovementMethod.getInstance()); messageText.setText(comment); if (isMine) { deleteButton.setVisibility(View.VISIBLE); deleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new DeleteInBg(context, String.valueOf(id)).execute(); mDialog.dismiss(); // TODO Refrescar las alertas } }); } closeButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mDialog.dismiss(); } }); mDialog.show(); }
From source file:com.eyekabob.util.EyekabobHelper.java
public static Dialog createAboutDialog(Context context) { final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.about_dialog); dialog.setTitle(R.string.about_eyekabob_caps); ImageView imageView = (ImageView) dialog.findViewById(R.id.aboutDialogImage); imageView.setImageResource(R.drawable.ic_launcher); String message = context.getResources().getString(R.string.eyekabob_version); String versionName = ""; try {// www .j a v a 2 s . co m versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { Log.e(context.getClass().getSimpleName(), e.getMessage()); } message += versionName; message += "\n\n" + context.getResources().getString(R.string.about_eyekabob_app); message += "\n\n" + context.getResources().getString(R.string.about_last_fm); TextView textView = (TextView) dialog.findViewById(R.id.aboutDialogText); textView.setText(message); dialog.findViewById(R.id.aboutDialogButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); } }); return dialog; }
From source file:com.nextgis.mobile.map.LocalGeoJsonLayer.java
protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName, final Uri uri, final LocalGeoJsonLayer layer) { final LinearLayout linearLayout = new LinearLayout(map.getContext()); final EditText input = new EditText(map.getContext()); input.setText(layerName);//from w w w . j a va 2 s . c o m final TextView stLayerName = new TextView(map.getContext()); stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":"); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(stLayerName); linearLayout.addView(input); if (!bCreate) { //TODO: style for drawing } 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) { if (bCreate) { create(map, input.getText().toString(), uri); } else { layer.setName(input.getText().toString()); 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 void addImgLinkText(final Context context, ArrayList<View> views, final String url, LinearLayout.LayoutParams params) { final TextView textView = new TextView(context); textView.setTextColor(Color.BLUE); textView.setLayoutParams(params);//from ww w . j av a 2 s . co m textView.setText("View image"); textView.setTextSize(getTextSize(context)); textView.setPadding(3, 3, 3, 3); textView.setTag(url); textView.setClickable(true); setupOnLinkClick(context, url, textView); views.add(textView); }
From source file:li.klass.fhem.adapter.devices.genericui.AvailableTargetStatesDialogUtil.java
public static <D extends FhemDevice<D>> void showSwitchOptionsMenu(final Context context, final D device, final TargetStateSelectedCallback callback) { AlertDialog.Builder contextMenu = new AlertDialog.Builder(context); contextMenu.setTitle(context.getResources().getString(R.string.switchDevice)); final List<String> setOptions = device.getSetList().getSortedKeys(); final String[] eventMapOptions = device.getAvailableTargetStatesEventMapTexts(); DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() { @Override/*from w ww. ja v a 2 s. c o m*/ public void onClick(DialogInterface dialog, int position) { final String option = setOptions.get(position); if (handleSelectedOption(context, device, option, callback)) return; dialog.dismiss(); } }; ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, R.layout.list_item_with_arrow, eventMapOptions) { @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = View.inflate(context, R.layout.list_item_with_arrow, null); } TextView textView = (TextView) convertView.findViewById(R.id.text); ImageView imageView = (ImageView) convertView.findViewById(R.id.image); textView.setText(getItem(position)); String setOption = setOptions.get(position); SetList setList = device.getSetList(); final SetListValue setListValue = setList.get(setOption); imageView.setVisibility(setListValue instanceof SetListGroupValue ? VISIBLE : GONE); return convertView; } }; contextMenu.setAdapter(adapter, clickListener); contextMenu.show(); }