List of usage examples for android.widget TextView setMovementMethod
public final void setMovementMethod(MovementMethod movement)
From source file:org.onebusaway.android.util.UIUtils.java
public static void setClickableSpan(TextView v, ClickableSpan span) { Spannable text = (Spannable) v.getText(); text.setSpan(span, 0, text.length(), 0); v.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.grokkingandroid.sampleapp.samples.data.contentprovider.about.AboutFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().setTitle(getResources().getString(R.string.cpsample_about)); View view = inflater.inflate(R.layout.fragment_about, container, false); ViewGroup libParent = (ViewGroup) view.findViewById(R.id.about_container); String[] libTitles = getResources().getStringArray(R.array.cpsample_about_titles); String[] libDescriptions = getResources().getStringArray(R.array.cpsample_about_contents); String libraryPlural = getResources().getQuantityString(R.plurals.cpsample_libraries_plural, libTitles.length);//from w ww . j a va 2s . c om String aboutText = getResources().getString(R.string.cpsample_about_text, libraryPlural); Spanned spannedAboutText = Html.fromHtml(aboutText); TextView aboutTv = (TextView) libParent.findViewById(R.id.about_text); aboutTv.setText(spannedAboutText); aboutTv.setMovementMethod(LinkMovementMethod.getInstance()); for (int i = 0; i < libTitles.length; i++) { View libContainer = inflater.inflate(R.layout.single_library_layout, libParent, false); TextView currLibTitle = (TextView) libContainer.findViewById(R.id.library_title); currLibTitle.setText(libTitles[i]); TextView currLibDesc = (TextView) libContainer.findViewById(R.id.library_text); Spanned spanned = Html.fromHtml(libDescriptions[i]); currLibDesc.setText(spanned); currLibDesc.setMovementMethod(LinkMovementMethod.getInstance()); libParent.addView(libContainer); } return view; }
From source file:com.liferay.mobile.screens.viewsets.westeros.auth.signup.SignUpView.java
private void initClickableTermsAndConditions() { TextView textView = (TextView) findViewById(R.id.terms); textView.setMovementMethod(LinkMovementMethod.getInstance()); SpannableStringBuilder ssb = new SpannableStringBuilder("I accept the terms and conditions"); ssb.setSpan(new ClickableSpan() { @Override//from w ww. jav a 2 s .c o m public void onClick(View widget) { SignUpScreenlet signUpScreenlet = getSignUpScreenlet(); signUpScreenlet.performUserAction(SignUpScreenlet.TERMS_AND_CONDITIONS); } }, 13, ssb.length(), 0); ssb.setSpan(new StyleSpan(Typeface.BOLD), 13, ssb.length(), 0); ssb.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getContext(), android.R.color.white)), 13, ssb.length(), 0); textView.setText(ssb, TextView.BufferType.SPANNABLE); }
From source file:com.color.kid.kidpaint.dialog.DialogAbout.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override//from ww w . ja va2s .co m public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); AlertDialog.Builder builder = new CustomAlertDialogBuilder(getActivity()); builder.setTitle(R.string.about_title); View view = inflater.inflate(R.layout.dialog_about, null); TextView aboutVersionNameTextView = (TextView) view.findViewById(R.id.dialog_about_version_name_text_view); String versionName = PaintroidApplication.getVersionName(getActivity()); aboutVersionNameTextView.setText(R.string.about_version); aboutVersionNameTextView.append(" " + versionName); TextView aboutTextView = (TextView) view.findViewById(R.id.about_tview_Text); String aboutText = String.format(getActivity().getString(R.string.about_content), getActivity().getString(R.string.license_type_paintroid)); aboutTextView.setText(aboutText); TextView aboutUrlTextView = (TextView) view.findViewById(R.id.about_tview_Url); aboutUrlTextView.setMovementMethod(LinkMovementMethod.getInstance()); Resources resources = getActivity().getResources(); /*String paintroidLicense = String.format( resources.getString(R.string.about_link_template), resources.getString(R.string.license_url), resources.getString(R.string.about_license_url_text)); aboutUrlTextView.append(Html.fromHtml(paintroidLicense)); aboutUrlTextView.append("\n\n"); String aboutCatroid = String.format( resources.getString(R.string.about_link_template), resources.getString(R.string.catroid_url), resources.getString(R.string.about_catroid_url_text));*/ //aboutUrlTextView.append(Html.fromHtml(aboutCatroid)); aboutUrlTextView.append("\n"); builder.setView(view); builder.setNeutralButton(R.string.done, this); return builder.create(); }
From source file:com.timothy.android.api.fragment.RightFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { activity = (SlidingActivity) getActivity(); mContext = activity.getApplicationContext(); sp = activity.getSharedPreferences("AndroidAPISP", 0); View view = inflater.inflate(R.layout.right, null); boolean syncFlag = SPUtil.getBooleanFromSP(SPUtil.SP_KEY_SYNC_FLAG, sp); //syncFlag//from w ww . j a v a2s . c om ToggleButton syncFlagBtn = (ToggleButton) view.findViewById(R.id.syncFlagBtn); syncFlagBtn.setChecked(syncFlag); syncFlagBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ToggleButton tb = (ToggleButton) v; SPUtil.save2SP(SPUtil.SP_KEY_SYNC_FLAG, tb.isChecked(), sp); } }); //lstReadTV TextView lstReadTV = (TextView) view.findViewById(R.id.lstReadTV); lstReadTV.setMovementMethod(ScrollingMovementMethod.getInstance()); int branchIndex = SPUtil.getIntegerFromSP(SPUtil.CURRENT_BRANCH_INDEX, sp); String[] contentsArray = activity.filterBranch(branchIndex); String contents = ContentUtil.getContentsById(contentsArray, SPUtil.getIntegerFromSP(SPUtil.CURRENT_INDEX, sp)); if (contents != null) { String[] contentArray = contents.split(","); if (contentArray != null && contentArray.length >= 4) { String contentName = contentArray[3]; lstReadTV.setText(contentName); } } Button gotoBtn = (Button) view.findViewById(R.id.gotoBtn); gotoBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { refreshActivity(); } }); return view; }
From source file:com.google.samples.apps.ledtoggler.UserConsentDialogFragment.java
@NonNull @Override/*w ww . j a v a 2 s . com*/ public Dialog onCreateDialog(Bundle savedInstanceState) { Spanned message = android.text.Html.fromHtml(getString(R.string.tos_confirmation)); TextView tv = new TextView(getActivity()); tv.setText(message); tv.setMovementMethod(LinkMovementMethod.getInstance()); tv.setTextSize(20); tv.setGravity(Gravity.CENTER); int spacingInPixels = dpsToPixels(16); AlertDialog dialog = new AlertDialog.Builder(getActivity()) .setView(tv, spacingInPixels, spacingInPixels, spacingInPixels, spacingInPixels) .setPositiveButton(R.string.tos_accept, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { onTosAccepted(); } }).setNegativeButton(R.string.tos_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { onTosRejected(); } }).create(); dialog.setCanceledOnTouchOutside(false); setCancelable(false); return dialog; }
From source file:org.catrobat.paintroid.dialog.DialogAbout.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override//from w ww .j a va2s.co m public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); AlertDialog.Builder builder; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { builder = new AlertDialog.Builder(getActivity()); } else { builder = new AlertDialog.Builder(getActivity(), AlertDialog.THEME_HOLO_DARK); } builder.setTitle(R.string.about_title); View view = inflater.inflate(R.layout.dialog_about, null); TextView aboutVersionNameTextView = (TextView) view.findViewById(R.id.dialog_about_version_name_text_view); String versionName = PaintroidApplication.getVersionName(getActivity()); aboutVersionNameTextView.setText(R.string.about_version); aboutVersionNameTextView.append(" " + versionName); TextView aboutTextView = (TextView) view.findViewById(R.id.about_tview_Text); String aboutText = String.format(getActivity().getString(R.string.about_content), getActivity().getString(R.string.licence_type_paintroid)); aboutTextView.setText(aboutText); TextView aboutUrlTextView = (TextView) view.findViewById(R.id.about_tview_Url); aboutUrlTextView.setMovementMethod(LinkMovementMethod.getInstance()); Resources resources = getActivity().getResources(); String paintroidLicence = String.format(resources.getString(R.string.about_link_template), resources.getString(R.string.license_url), resources.getString(R.string.about_licence_url_text)); aboutUrlTextView.append(Html.fromHtml(paintroidLicence)); aboutUrlTextView.append("\n\n"); String aboutCatroid = String.format(resources.getString(R.string.about_link_template), resources.getString(R.string.catroid_url), resources.getString(R.string.about_catroid_url_text)); aboutUrlTextView.append(Html.fromHtml(aboutCatroid)); aboutUrlTextView.append("\n"); builder.setView(view); builder.setNeutralButton(R.string.done, this); return builder.create(); }
From source file:siarhei.luskanau.gps.tracker.free.ui.dialog.AboutFragment.java
@Override public void onResume() { super.onResume(); try {//from w w w.java 2 s . co m TextView messageTextView = (TextView) getDialog().findViewById(android.R.id.message); if (messageTextView != null) { messageTextView.setMovementMethod(LinkMovementMethod.getInstance()); } } catch (Throwable t) { Log.e(TAG, t.toString(), t); } }
From source file:it.reyboz.bustorino.ActivityAbout.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); Spanned htmlText = Html.fromHtml(getResources().getString(R.string.about_history)); TextView aboutTextView = (TextView) findViewById(R.id.aboutTextView); assert aboutTextView != null; aboutTextView.setText(htmlText);/*from ww w . j a v a 2s .com*/ aboutTextView.setMovementMethod(LinkMovementMethod.getInstance()); // Back button ActionBar ab = getSupportActionBar(); assert ab != null; ab.setDisplayHomeAsUpEnabled(true); }
From source file:com.manning.androidhacks.hack010.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from w ww .ja v a 2 s.c om final TextView textView1 = (TextView) findViewById(R.id.my_text_view_html); textView1.setText(Html.fromHtml(getString(R.string.text1))); textView1.setMovementMethod(LinkMovementMethod.getInstance()); final Spannable text2 = new SpannableString(getString(R.string.text2)); text2.setSpan(new BackgroundColorSpan(Color.RED), 1, 4, 0); text2.setSpan(new ForegroundColorSpan(Color.BLUE), 5, 9, 0); ((TextView) findViewById(R.id.my_text_view_spannable)).setText(text2); }