List of usage examples for android.widget TextView append
public final void append(CharSequence text)
From source file:ngoc.com.pedometer.ui.Fragment_Overview.java
private void showAboutDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.about);//from w ww . j a v a2 s . c o m TextView tv = new TextView(getActivity()); tv.setPadding(10, 10, 10, 10); tv.setText(R.string.about_text_links); try { tv.append(getString(R.string.about_app_version, getActivity().getPackageManager() .getPackageInfo(getActivity().getPackageName(), 0).versionName)); } catch (PackageManager.NameNotFoundException e1) { // should not happen as the app is definitely installed when // seeing the dialog e1.printStackTrace(); } tv.setMovementMethod(LinkMovementMethod.getInstance()); builder.setView(tv); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); }
From source file:org.exobel.routerkeygen.ui.Preferences.java
protected Dialog onCreateDialog(int id) { AlertDialog.Builder builder = new Builder(this); switch (id) { case DIALOG_ABOUT: { LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.about_dialog, (ViewGroup) findViewById(R.id.tabhost)); TabHost tabs = (TabHost) layout.findViewById(R.id.tabhost); tabs.setup();/*w w w. j av a2 s . c o m*/ TabSpec tspec1 = tabs.newTabSpec("about"); tspec1.setIndicator(getString(R.string.pref_about)); tspec1.setContent(R.id.text_about_scroll); TextView text = ((TextView) layout.findViewById(R.id.text_about)); text.setMovementMethod(LinkMovementMethod.getInstance()); text.append(VERSION + "\n" + LAUNCH_DATE); tabs.addTab(tspec1); TabSpec tspec2 = tabs.newTabSpec("credits"); tspec2.setIndicator(getString(R.string.dialog_about_credits)); tspec2.setContent(R.id.about_credits_scroll); ((TextView) layout.findViewById(R.id.about_credits)) .setMovementMethod(LinkMovementMethod.getInstance()); tabs.addTab(tspec2); TabSpec tspec3 = tabs.newTabSpec("license"); tspec3.setIndicator(getString(R.string.dialog_about_license)); tspec3.setContent(R.id.about_license_scroll); ((TextView) layout.findViewById(R.id.about_license)) .setMovementMethod(LinkMovementMethod.getInstance()); tabs.addTab(tspec3); builder.setNeutralButton(R.string.bt_close, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { removeDialog(DIALOG_ABOUT); } }); builder.setView(layout); break; } case DIALOG_ASK_DOWNLOAD: { DialogInterface.OnClickListener diOnClickListener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Check if we have the latest dictionary version. try { checkCurrentDictionary(); } catch (Exception e) { e.printStackTrace(); } } }; builder.setTitle(R.string.pref_download); builder.setMessage(R.string.msg_dicislarge); builder.setCancelable(false); builder.setPositiveButton(android.R.string.yes, diOnClickListener); builder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { removeDialog(DIALOG_ASK_DOWNLOAD); } }); break; } case DIALOG_UPDATE_NEEDED: { builder.setTitle(R.string.update_title) .setMessage(getString(R.string.update_message, lastVersion.version)) .setNegativeButton(R.string.bt_close, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { removeDialog(DIALOG_UPDATE_NEEDED); } }).setPositiveButton(R.string.bt_website, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(lastVersion.url))); } }); break; } case DIALOG_WAIT: { ProgressDialog pbarDialog = new ProgressDialog(Preferences.this); pbarDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pbarDialog.setMessage(getString(R.string.msg_wait)); return pbarDialog; } case DIALOG_ERROR_TOO_ADVANCED: { builder.setTitle(R.string.msg_error).setMessage(R.string.msg_err_online_too_adv); break; } case DIALOG_ERROR: { builder.setTitle(R.string.msg_error).setMessage(R.string.msg_err_unkown); break; } case DIALOG_CHANGELOG: { LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); ChangeLogListView chgList = (ChangeLogListView) layoutInflater.inflate(R.layout.dialog_changelog, (ViewGroup) this.getWindow().getDecorView().getRootView(), false); builder.setTitle(R.string.pref_changelog).setView(chgList).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }); break; } } return builder.create(); }
From source file:liqui.droid.activity.Base.java
/** * Creates the breadcrumb./* w w w . j ava 2s.c om*/ * * @param subTitle the sub title * @param breadCrumbHolders the bread crumb holders */ public void createBreadcrumb(String subTitle, BreadCrumbHolder... breadCrumbHolders) { if (breadCrumbHolders != null) { LinearLayout llPart = (LinearLayout) this.findViewById(R.id.ll_part); for (int i = 0; i < breadCrumbHolders.length; i++) { TextView tvBreadCrumb = new TextView(getApplication()); SpannableString part = new SpannableString(breadCrumbHolders[i].getLabel()); part.setSpan(new UnderlineSpan(), 0, part.length(), 0); tvBreadCrumb.append(part); tvBreadCrumb.setTag(breadCrumbHolders[i]); tvBreadCrumb.setBackgroundResource(R.drawable.default_link); tvBreadCrumb.setTextAppearance(getApplication(), R.style.default_text_small); tvBreadCrumb.setSingleLine(true); tvBreadCrumb.setOnClickListener(new OnClickBreadCrumb(this)); llPart.addView(tvBreadCrumb); if (i < breadCrumbHolders.length - 1) { TextView slash = new TextView(getApplication()); slash.setText(" / "); slash.setTextAppearance(getApplication(), R.style.default_text_small); llPart.addView(slash); } } } ScrollingTextView tvSubtitle = (ScrollingTextView) this.findViewById(R.id.tv_subtitle); tvSubtitle.setText(subTitle); }
From source file:com.doomonafireball.hackerswiperfree.android.activity.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.get_hacker_swiper_pro: Intent hsProIntent = new Intent(Intent.ACTION_VIEW); hsProIntent.setData(Uri.parse(/*from w w w . j av a2s . c om*/ "http://play.google.com/store/apps/details?id=com.doomonafireball.hackerswiperpro.android")); startActivity(hsProIntent); return true; case R.id.about: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.about_hacker_swiper); final TextView aboutText = new TextView(this); int padding = getResources().getDimensionPixelSize(R.dimen.default_padding); aboutText.setPadding(padding, padding, padding, padding); String appVersionName = "x.x"; int appVersionCode = 0; try { appVersionName = getApplication().getPackageManager() .getPackageInfo(getApplication().getPackageName(), 0).versionName; appVersionCode = getApplication().getPackageManager() .getPackageInfo(getApplication().getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException e) { //Failed } aboutText.setText(Html.fromHtml(getString(R.string.about_hacker_swiper_text))); aboutText.append( String.format(getString(R.string.version_dynamic), appVersionName + " b" + appVersionCode)); aboutText.append("\n"); SpannableString openSourceLink = makeLinkSpan(getString(R.string.open_source_licenses), new View.OnClickListener() { @Override public void onClick(View v) { showOpenSourceDialog(); } }); aboutText.append(openSourceLink); aboutText.append("\n"); aboutText.setFocusable(false); makeLinksFocusable(aboutText); builder.setView(aboutText); builder.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }); builder.show(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:eu.trentorise.smartcampus.trentinofamiglia.fragments.track.TrackListingFragment.java
@Override public void onStart() { // hide keyboard if it is still open Utils.hideKeyboard(getActivity());/*from w w w . j ava2 s. c om*/ if (reload) { trackAdapter = new TrackAdapter(context, R.layout.tracks_row); setAdapter(trackAdapter); reload = false; } Bundle bundle = this.getArguments(); String category = (bundle != null) ? bundle.getString(SearchFragment.ARG_CATEGORY) : null; CategoryDescriptor catDescriptor = CategoryHelper .getCategoryDescriptorByCategoryFiltered(CategoryHelper.CATEGORY_TYPE_TRACKS, category); String categoryString = (catDescriptor != null) ? context.getResources().getString(catDescriptor.description) : null; // set title TextView title = (TextView) getView().findViewById(R.id.list_title); if (categoryString != null) { title.setText(categoryString); } if (bundle != null && bundle.containsKey(SearchFragment.ARG_QUERY) && bundle.getString(SearchFragment.ARG_QUERY) != null) { String query = bundle.getString(SearchFragment.ARG_QUERY); title.setText(context.getResources().getString(R.string.search_for) + " ' " + query + " '"); if (bundle.containsKey(SearchFragment.ARG_CATEGORY)) { category = bundle.getString(SearchFragment.ARG_CATEGORY); if (category != null) title.append(" " + context.getResources().getString(R.string.search_in_category) + " " + getString(catDescriptor.description)); } } if (bundle.containsKey(SearchFragment.ARG_WHERE_SEARCH)) { WhereForSearch where = bundle.getParcelable(SearchFragment.ARG_WHERE_SEARCH); if (where != null) title.append(" " + where.getDescription() + " "); } // close items menus if open ((View) list.getParent()).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { hideListItemsMenu(v, false); } }); list.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { hideListItemsMenu(view, false); setStoredTrackId(view, position); } }); super.onStart(); }
From source file:eu.trentorise.smartcampus.trentinofamiglia.fragments.info.InfoListingFragment.java
@Override public void onStart() { // hide keyboard if it is still open Utils.hideKeyboard(getActivity());// ww w .j a va 2 s .c o m if (reload) { infoAdapter = new InfoAdapter(context, R.layout.infos_row); setAdapter(infoAdapter); reload = false; } Bundle bundle = this.getArguments(); String category = (bundle != null) ? bundle.getString(SearchFragment.ARG_CATEGORY) : null; CategoryDescriptor catDescriptor = CategoryHelper .getCategoryDescriptorByCategoryFiltered(CategoryHelper.CATEGORY_TYPE_INFOS, category); String categoryString = (catDescriptor != null) ? context.getResources().getString(catDescriptor.description) : null; warningToast(catDescriptor); // set title TextView title = (TextView) getView().findViewById(R.id.list_title); if (categoryString != null) { title.setText(categoryString); } if (bundle != null && bundle.containsKey(SearchFragment.ARG_QUERY) && bundle.getString(SearchFragment.ARG_QUERY) != null) { String query = bundle.getString(SearchFragment.ARG_QUERY); title.setText(context.getResources().getString(R.string.search_for) + " ' " + query + " '"); if (bundle.containsKey(SearchFragment.ARG_CATEGORY)) { category = bundle.getString(SearchFragment.ARG_CATEGORY); if (category != null) title.append(" " + context.getResources().getString(R.string.search_in_category) + " " + getString(catDescriptor.description)); } } if (bundle.containsKey(SearchFragment.ARG_WHERE_SEARCH)) { WhereForSearch where = bundle.getParcelable(SearchFragment.ARG_WHERE_SEARCH); if (where != null) title.append(" " + where.getDescription() + " "); } // close items menus if open ((View) list.getParent()).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { hideListItemsMenu(v, false); } }); list.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { hideListItemsMenu(view, false); setStoredTrackId(view, position); } }); super.onStart(); }
From source file:cw.kop.autobackground.tutorial.FinishFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tutorial_finish_fragment, container, false); int colorFilterInt = AppSettings.getColorFilterInt(appContext); TextView titleText = (TextView) view.findViewById(R.id.title_text); titleText.setTextColor(colorFilterInt); titleText.setText("That's it."); TextView tutorialText = (TextView) view.findViewById(R.id.tutorial_text); tutorialText.setTextColor(colorFilterInt); tutorialText.setText("Now you're ready to use AutoBackground. I'd suggest adding a new source first " + "and then hitting download." + "\n" + "\n" + "If you have any questions, concerns, suggestions, or whatever else, feel free to " + "email me at "); SpannableString emailString = new SpannableString("chiuwinson@gmail.com"); ClickableSpan clickableSpan = new ClickableSpan() { @Override//from w w w.jav a 2 s . c o m public void onClick(View widget) { Log.i(TAG, "Clicked"); Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "chiuwinson@gmail.com", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "AutoBackground Feedback"); startActivity(Intent.createChooser(emailIntent, "Send email")); } }; emailString.setSpan(clickableSpan, 0, emailString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); tutorialText.append(emailString); tutorialText.append("."); tutorialText.setMovementMethod(LinkMovementMethod.getInstance()); return view; }
From source file:com.google.zxing.client.android.result.supplement.SupplementalInfoRetriever.java
final void append(String itemID, String source, String[] newTexts, String linkURL) throws InterruptedException { final TextView textView = textViewRef.get(); if (textView == null) { throw new InterruptedException(); }//from ww w. j a va 2s.co m StringBuilder newTextCombined = new StringBuilder(); if (source != null) { newTextCombined.append(source).append(" : "); } int linkStart = newTextCombined.length(); boolean first = true; for (String newText : newTexts) { if (first) { newTextCombined.append(newText); first = false; } else { newTextCombined.append(" ["); newTextCombined.append(newText); newTextCombined.append(']'); } } int linkEnd = newTextCombined.length(); String newText = newTextCombined.toString(); final Spannable content = new SpannableString(newText + "\n\n"); if (linkURL != null) { content.setSpan(new URLSpan(linkURL), linkStart, linkEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } handler.post(new Runnable() { public void run() { textView.append(content); textView.setMovementMethod(LinkMovementMethod.getInstance()); } }); // Add the text to the history. historyManager.addHistoryItemDetails(itemID, newText); }
From source file:com.joyepay.qrcode.result.supplement.SupplementalInfoRetriever.java
final void append(String itemID, String source, String[] newTexts, String linkURL) throws InterruptedException { final TextView textView = textViewRef.get(); if (textView == null) { throw new InterruptedException(); }// w w w . jav a 2s . c o m StringBuilder newTextCombined = new StringBuilder(); if (source != null) { newTextCombined.append(source).append(" : "); } int linkStart = newTextCombined.length(); boolean first = true; for (String newText : newTexts) { if (first) { newTextCombined.append(newText); first = false; } else { newTextCombined.append(" ["); newTextCombined.append(newText); newTextCombined.append(']'); } } int linkEnd = newTextCombined.length(); String newText = newTextCombined.toString(); final Spannable content = new SpannableString(newText + "\n\n"); if (linkURL != null) { content.setSpan(new URLSpan(linkURL), linkStart, linkEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } handler.post(new Runnable() { public void run() { textView.append(content); textView.setMovementMethod(LinkMovementMethod.getInstance()); } }); // Add the text to the history. // historyManager.addHistoryItemDetails(itemID, newText); }
From source file:org.akvo.caddisfly.sensor.colorimetry.strip.instructions.InstructionDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_instruction_detail, container, false); Drawable instructionDrawable = AssetsManager.getImage(getActivity(), getArguments().getString(ARG_ITEM_IMAGE)); if (instructionDrawable != null) { ((ImageView) rootView.findViewById(R.id.image_illustration)).setImageDrawable(instructionDrawable); }//from www. ja v a 2 s. co m ArrayList<String> instructionText = getArguments().getStringArrayList(ARG_ITEM_TEXT); if (instructionText != null) { LinearLayout linearLayout = (LinearLayout) rootView.findViewById(R.id.layout_instructions); for (String instruction : instructionText) { TextView textView = new TextView(getActivity()); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.mediumTextSize)); textView.setPadding(0, 0, 0, (int) getResources().getDimension(R.dimen.activity_vertical_margin)); textView.setLineSpacing(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5.0f, getResources().getDisplayMetrics()), 1.0f); String text = instruction; if (instruction.contains("<!>")) { text = instruction.replaceAll("<!>", ""); textView.setTextColor(Color.RED); } else { textView.setTextColor(Color.DKGRAY); } if (instruction.contains("<b>")) { text = text.replaceAll("<b>", "").replaceAll("</b>", ""); textView.setTypeface(null, Typeface.BOLD); } else { textView.setTextColor(Color.DKGRAY); } Spanned spanned = StringUtil.getStringResourceByName(getContext(), text); if (!text.isEmpty()) { textView.append(spanned); linearLayout.addView(textView); } } } return rootView; }