Example usage for android.widget TextView setMovementMethod

List of usage examples for android.widget TextView setMovementMethod

Introduction

In this page you can find the example usage for android.widget TextView setMovementMethod.

Prototype

public final void setMovementMethod(MovementMethod movement) 

Source Link

Document

Sets the android.text.method.MovementMethod for handling arrow key movement for this TextView.

Usage

From source file:com.slushpupie.deskclock.ChangelogDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Standard AlertDialog does not support HTML-style links.
    // So rebuild the ScrollView->TextView with the appropriate
    // settings and set the view directly.
    TextView tv = new TextView(getActivity());
    tv.setPadding(5, 5, 5, 5);//from   ww  w  .  jav  a 2s . co  m
    tv.setLinksClickable(true);
    tv.setMovementMethod(LinkMovementMethod.getInstance());
    tv.setText(R.string.changeLog);
    tv.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium);
    ScrollView sv = new ScrollView(getActivity());
    sv.setPadding(14, 2, 10, 12);
    sv.addView(tv);
    builder.setView(sv).setCancelable(false).setTitle(R.string.changeLogTitle).setPositiveButton(R.string.ok,
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    ((DeskClock) getActivity()).acknoledgeChangelog();
                }
            });
    return builder.create();
}

From source file:com.google.android.apps.gutenberg.EulaFragment.java

@NonNull
@Override//from   ww  w. j a v a 2  s .  co m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int padding = getResources().getDimensionPixelSize(R.dimen.dialog_padding);
    TextView eulaTextView = new TextView(getActivity());
    eulaTextView.setText(Html.fromHtml(getString(R.string.eula_content)));
    eulaTextView.setMovementMethod(LinkMovementMethod.getInstance());
    eulaTextView.setPadding(padding, padding, padding, padding);
    return new AlertDialog.Builder(getActivity()).setTitle(R.string.eula).setView(eulaTextView)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:com.forrestguice.suntimeswidget.AboutDialog.java

public void initViews(Context context, View dialogContent) {
    TextView versionView = (TextView) dialogContent.findViewById(R.id.txt_about_version);
    versionView.setMovementMethod(LinkMovementMethod.getInstance());
    versionView.setText(Html.fromHtml(htmlVersionString()));

    TextView urlView = (TextView) dialogContent.findViewById(R.id.txt_about_url);
    urlView.setMovementMethod(LinkMovementMethod.getInstance());
    urlView.setText(Html.fromHtml(context.getString(R.string.app_url)));

    TextView supportView = (TextView) dialogContent.findViewById(R.id.txt_about_support);
    supportView.setMovementMethod(LinkMovementMethod.getInstance());
    supportView.setText(Html.fromHtml(context.getString(R.string.app_support_url)));

    TextView legalView1 = (TextView) dialogContent.findViewById(R.id.txt_about_legal1);
    legalView1.setMovementMethod(LinkMovementMethod.getInstance());
    legalView1.setText(Html.fromHtml(context.getString(R.string.app_legal1)));

    TextView legalView2 = (TextView) dialogContent.findViewById(R.id.txt_about_legal2);
    legalView2.setMovementMethod(LinkMovementMethod.getInstance());
    legalView2.setText(Html.fromHtml(context.getString(R.string.app_legal2)));

    TextView legalView3 = (TextView) dialogContent.findViewById(R.id.txt_about_legal3);
    legalView3.setMovementMethod(LinkMovementMethod.getInstance());
    legalView3.setText(Html.fromHtml(context.getString(R.string.app_legal3)));
}

From source file:com.rgam.morsekeyboard.SettingsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.settings_fragment, container, false);

    predictiveButton = (Button) view.findViewById(R.id.predictiveButton);
    predictiveButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            SharedPreferences settings = getActivity().getSharedPreferences(Constants.GTAP_PREFS, 0);
            SharedPreferences.Editor editor = settings.edit();

            boolean predictive = !settings.getBoolean(Constants.GTAP_PREDICTIVE_MODE, false);
            editor.putBoolean(Constants.GTAP_PREDICTIVE_MODE, predictive);
            editor.commit();/*www. ja va 2  s  .c  om*/

            drawUI();
        }
    });

    TextView apache = (TextView) view.findViewById(R.id.apache_text);
    apache.setMovementMethod(new ScrollingMovementMethod());

    return view;
}

From source file:com.battlelancer.seriesguide.ui.dialogs.ChangesDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View layout = inflater.inflate(R.layout.changes_dialog, null);

    // title/*from   w ww  .  j  a v a2s. c  o  m*/
    ((TextView) layout.findViewById(R.id.title)).setText(getString(R.string.app_name));

    // message
    TextView message = (TextView) layout.findViewById(R.id.message);
    message.setMovementMethod(LinkMovementMethod.getInstance());

    // buttons
    Button buttonNegative = (Button) layout.findViewById(R.id.buttonNegative);
    buttonNegative.setText(R.string.download_stable);
    buttonNegative.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(MARKETLINK_APP));
                startActivity(myIntent);
            } catch (ActivityNotFoundException e) {
                Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(MARKETLINK_HTTP));
                startActivity(myIntent);
            }
        }
    });
    Button buttonPositive = (Button) layout.findViewById(R.id.buttonPositive);
    buttonPositive.setText(R.string.gobreak);
    buttonPositive.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });

    return layout;
}

From source file:com.connectsdk.smarthomesampler.dialog.AcknowledgementsFragmentDialog.java

@NonNull
@Override//from  ww w.  j  av a2s  .  com
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();
    final TextView message = new TextView(context);
    message.setText(Html.fromHtml(context.getString(R.string.info_message)));
    message.setMovementMethod(LinkMovementMethod.getInstance());
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25,
            context.getResources().getDisplayMetrics());
    message.setPadding(padding, 0, padding, 0);
    ScrollView scrollView = new ScrollView(context);
    scrollView.addView(message);

    return new AlertDialog.Builder(context).setTitle(R.string.info_title).setView(scrollView)
            .setCancelable(true).create();
}

From source file:com.siyuan.muzei.ample.settings.AboutActivity.java

void setupBody() {
    TextView view = (TextView) findViewById(R.id.about_body);
    view.setText(Html.fromHtml(getString(R.string.about_body)));
    view.setMovementMethod(new LinkMovementMethod());
}

From source file:fr.tvbarthel.apps.simpleweatherforcast.fragments.LicenseDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final LayoutInflater inflater = getActivity().getLayoutInflater();

    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
    final View dialogView = inflater.inflate(R.layout.dialog_license, null);

    if (dialogView != null) {
        final TextView textViewContent = (TextView) dialogView.findViewById(R.id.dialog_license_content);
        if (textViewContent != null) {
            textViewContent.setMovementMethod(LinkMovementMethod.getInstance());
            Linkify.addLinks(textViewContent, Linkify.WEB_URLS);
        }//from w w  w .ja  v  a2  s. c  o  m
    }

    dialogBuilder.setCancelable(true).setView(dialogView).setPositiveButton(android.R.string.ok, null)
            .setTitle(R.string.dialog_license_title).setInverseBackgroundForced(true);

    return dialogBuilder.create();
}

From source file:org.catrobat.catroid.ui.dialogs.AboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle bundle) {
    View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_about, null);

    TextView aboutUrlTextView = (TextView) view.findViewById(R.id.dialog_about_text_view_url);
    aboutUrlTextView.setMovementMethod(LinkMovementMethod.getInstance());

    String aboutUrl = getString(R.string.about_link_template, Constants.ABOUT_POCKETCODE_LICENSE_URL,
            getString(R.string.dialog_about_pocketcode_license_link_text));

    aboutUrlTextView.setText(Html.fromHtml(aboutUrl));

    TextView aboutUrlCatrobatView = (TextView) view.findViewById(R.id.dialog_about_text_catrobat_url);
    aboutUrlCatrobatView.setMovementMethod(LinkMovementMethod.getInstance());

    String aboutCatrobatUrl = getString(R.string.about_link_template, Constants.CATROBAT_ABOUT_URL,
            getString(R.string.dialog_about_catrobat_link_text));

    aboutUrlCatrobatView.setText(Html.fromHtml(aboutCatrobatUrl));

    TextView aboutVersionNameTextView = (TextView) view.findViewById(R.id.dialog_about_text_view_version_name);
    String versionName = this.getString(R.string.android_version_prefix) + Utils.getVersionName(getActivity());
    aboutVersionNameTextView.setText(versionName);

    Dialog aboutDialog = new AlertDialog.Builder(getActivity()).setView(view)
            .setTitle(R.string.dialog_about_title)
            .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
                @Override/*  w w w . j  ava  2s .c o  m*/
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            }).create();
    aboutDialog.setCanceledOnTouchOutside(true);

    return aboutDialog;
}

From source file:com.github.michalbednarski.intentslab.TextFragment.java

private void putTextInView() {
    if (mText instanceof CharSequence[]) {
        mFakeLongText.setAdapter(new ArrayAdapter<CharSequence>(getActivity(), 0, (CharSequence[]) mText) {
            @Override/*from   w w  w. j  av  a 2s.c o  m*/
            public View getView(int position, View convertView, ViewGroup parent) {
                if (convertView == null) {
                    final TextView textView = new TextView(getContext());
                    textView.setMovementMethod(LinkMovementMethod.getInstance());
                    convertView = textView;
                }
                ((TextView) convertView).setText(getItem(position));
                return convertView;
            }

            @Override
            public boolean areAllItemsEnabled() {
                return false;
            }

            @Override
            public boolean isEnabled(int position) {
                return false;
            }
        });
        mFakeLongText.setVisibility(View.VISIBLE);
    } else {
        mXmlTextView.setText((CharSequence) mText);
        mXmlWrapperView.setVisibility(View.VISIBLE);
    }

    mLoaderView.setVisibility(View.GONE);
}