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.derdoktor667.dev.thematrix.fragments.overview.OverviewFragment.java

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

    PackageManager pm;/*from  ww  w.  j a va  2 s.  co  m*/
    pm = getActivity().getPackageManager();
    String packageName = getActivity().getPackageName();
    String versionName = null;

    try {
        PackageInfo info = null;

        if (pm != null) {
            info = pm.getPackageInfo(packageName, 0);
        }

        if (info != null) {
            versionName = info.versionName;
        }

    } catch (PackageManager.NameNotFoundException e) {
        versionName = VERSION_UNAVAILABLE;
    }

    TextView nameAndVersionView = null;

    if (view != null) {
        nameAndVersionView = (TextView) view.findViewById(R.id.app_name_and_version);
    }

    if (nameAndVersionView != null) {
        nameAndVersionView.setText(Html.fromHtml(getString(R.string.app_name_and_version, versionName)));
    }

    TextView aboutBodyView = null;

    if (view != null) {
        aboutBodyView = (TextView) view.findViewById(R.id.about_body);
    }

    if (aboutBodyView != null) {
        aboutBodyView.setText(Html.fromHtml(getString(R.string.about_body)));
    }

    if (aboutBodyView != null) {
        aboutBodyView.setMovementMethod(new LinkMovementMethod());
    }

    return view;
}

From source file:ca.ualberta.cmput301w14t08.geochan.fragments.PostFragment.java

/**
 * Initializes some UI elements if the user is posting a reply rather than a new ThreadComment.
 *//* w  w  w . j a  v a2  s.c om*/
@Override
public void onStart() {
    super.onStart();
    if (commentToReplyTo != null) {
        TextView replyTo = (TextView) getActivity().findViewById(R.id.comment_replyingTo);
        TextView bodyReplyTo = (TextView) getActivity().findViewById(R.id.reply_to_body);
        bodyReplyTo.setMovementMethod(new ScrollingMovementMethod());
        bodyReplyTo.setText(commentToReplyTo.getTextPost());
        replyTo.setText(commentToReplyTo.getUser() + " says:");
    }
}

From source file:com.tmendes.birthdaydroid.AboutUsFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_about_us, container, false);

    TextView appVersion = (TextView) v.findViewById(R.id.tvVersion);
    TextView tvHelpDevel = (TextView) v.findViewById(R.id.tvHelpDevel);
    TextView tvHelpIssue = (TextView) v.findViewById(R.id.tvHelpIssue);
    TextView tvHelpTranslator = (TextView) v.findViewById(R.id.tvHelpTranslator);
    TextView tvIcons01 = (TextView) v.findViewById(R.id.tvIcons01);
    TextView tvTranslatorNames = (TextView) v.findViewById(R.id.tvTranslatorNames);

    tvHelpDevel.setMovementMethod(LinkMovementMethod.getInstance());
    tvHelpIssue.setMovementMethod(LinkMovementMethod.getInstance());
    tvHelpTranslator.setMovementMethod(LinkMovementMethod.getInstance());
    tvIcons01.setMovementMethod(LinkMovementMethod.getInstance());
    tvTranslatorNames.setMovementMethod(LinkMovementMethod.getInstance());

    appVersion//from   w  w  w  . j  av a 2 s . c  o  m
            .setText(container.getContext().getResources().getString(R.string.build, BuildConfig.VERSION_CODE));

    return v;

}

From source file:com.google.reviewit.ServerSettingsFragment.java

private void displayCredentialsInfo(String url) {
    if (Strings.isNullOrEmpty(url)) {
        setGone(v(R.id.crendentialsInfo, R.id.credentialsInfoText, R.id.pasteCredentialsButton));
        return;//ww w.ja  v  a 2 s  .co m
    }

    TextView credentialsInfo = (TextView) v(R.id.credentialsInfoText);
    credentialsInfo.setMovementMethod(LinkMovementMethod.getInstance());
    url = FormatUtil.ensureSlash(url);

    String host;
    try {
        host = new URL(url).getHost();
    } catch (MalformedURLException e) {
        setGone(v(R.id.crendentialsInfo, R.id.credentialsInfoText, R.id.pasteCredentialsButton));
        return;
    }

    if (host.endsWith(".googlesource.com")) {
        url += "new-password";
        credentialsInfo.setText(Html.fromHtml(getString(R.string.credentials_info_googlesource,
                createLink(url, getString(R.string.googlesource_obtain_password)))));
        setVisible(v(R.id.crendentialsInfo, R.id.credentialsInfoText, R.id.pasteCredentialsButton));
    } else {
        url += "#/settings/http-password";
        credentialsInfo.setText(Html.fromHtml(
                getString(R.string.credentials_info, createLink(url, getString(R.string.http_password)))));
        setGone(v(R.id.pasteCredentialsButton));
        setVisible(v(R.id.crendentialsInfo, R.id.credentialsInfoText));
    }
}

From source file:de.grobox.transportr.about.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_about, container, false);
    Activity activity = getActivity();//  ww  w .  j a  va 2s.c  o  m

    String versionName;
    try {
        if (activity == null)
            throw new NameNotFoundException();
        versionName = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {
        versionName = "?.?";
    }

    // add app name and version
    TextView aboutApp = view.findViewById(R.id.aboutApp);
    aboutApp.setText(getResources().getString(R.string.app_name) + "  " + versionName);

    // create real paragraphs
    TextView t = view.findViewById(R.id.aboutTextView);
    t.setText(Html.fromHtml(getString(R.string.about)
            + String.format(getString(R.string.about_bottom), getString(R.string.website),
                    getString(R.string.bugtracker), getString(R.string.website) + "#donate")));

    // make links in about text clickable
    t.setMovementMethod(LinkMovementMethod.getInstance());
    t.setLinkTextColor(ContextCompat.getColor(getContext(), R.color.accent));

    Button website = view.findViewById(R.id.websiteButton);
    website.setOnClickListener(v -> {
        Intent launchBrowser = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.website)));
        startActivity(launchBrowser);
    });

    return view;
}

From source file:de.grobox.liberario.fragments.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_about, container, false);
    Activity activity = getActivity();/*  w ww  .ja va  2 s. c  o m*/

    String versionName;
    try {
        versionName = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0).versionName;
    } catch (PackageManager.NameNotFoundException e) {
        versionName = "?.?";
    }

    // add app name and version
    TextView aboutApp = (TextView) view.findViewById(R.id.aboutApp);
    aboutApp.setText(getResources().getString(R.string.app_name) + "  " + versionName);

    // create real paragraphs
    TextView t = (TextView) view.findViewById(R.id.aboutTextView);
    t.setText(Html.fromHtml(getString(R.string.about)
            + String.format(getString(R.string.about_bottom), getString(R.string.website),
                    getString(R.string.bugtracker), getString(R.string.website) + "#donate")));

    // make links in about text clickable
    t.setMovementMethod(LinkMovementMethod.getInstance());
    t.setLinkTextColor(ContextCompat.getColor(activity, R.color.accent));

    Button website = (Button) view.findViewById(R.id.websiteButton);
    website.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent launchBrowser = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.website)));
            startActivity(launchBrowser);
        }
    });

    return view;
}

From source file:com.androzic.About.java

private void updateAboutInfo(final View view) {
    // version//from   ww  w . j av a 2s  .c  o  m
    String versionName = null;
    int versionBuild = 0;
    try {
        versionName = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(),
                0).versionName;
        versionBuild = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(),
                0).versionCode;
    } catch (NameNotFoundException ex) {
        versionName = "unable to retreive version";
    }
    final TextView version = (TextView) view.findViewById(R.id.version);
    version.setText(getString(R.string.version, versionName, versionBuild));

    // home links
    StringBuilder links = new StringBuilder();
    links.append("<a href=\"");
    links.append(": http://androzic.com");
    links.append("\">");
    links.append(getString(R.string.homepage));
    links.append("</a><br /><a href=\"");
    links.append(getString(R.string.faquri));
    links.append("\">");
    links.append(getString(R.string.faq));
    links.append("</a><br /><a href=\"");
    links.append(getString(R.string.featureuri));
    links.append("\">");
    links.append(getString(R.string.feedback));
    links.append("</a>");
    final TextView homelinks = (TextView) view.findViewById(R.id.homelinks);
    homelinks.setText(Html.fromHtml(links.toString()));
    homelinks.setMovementMethod(LinkMovementMethod.getInstance());

    // community links
    StringBuilder communities = new StringBuilder();
    communities.append("<a href=\"");
    communities.append(getString(R.string.googleplusuri));
    communities.append("\">");
    communities.append(getString(R.string.googleplus));
    communities.append("</a><br /><a href=\"");
    communities.append(getString(R.string.facebookuri));
    communities.append("\">");
    communities.append(getString(R.string.facebook));
    communities.append("</a><br /><a href=\"");
    communities.append(getString(R.string.twitteruri));
    communities.append("\">");
    communities.append(getString(R.string.twitter));
    communities.append("</a>");
    final TextView communitylinks = (TextView) view.findViewById(R.id.communitylinks);
    communitylinks.setText(Html.fromHtml(communities.toString()));
    communitylinks.setMovementMethod(LinkMovementMethod.getInstance());

    // donations
    StringBuilder donations = new StringBuilder();
    donations.append("<a href=\"");
    donations.append(getString(R.string.playuri));
    donations.append("\">");
    donations.append(getString(R.string.donate_google));
    donations.append("</a><br /><a href=\"");
    donations.append(getString(R.string.paypaluri));
    donations.append("\">");
    donations.append(getString(R.string.donate_paypal));
    donations.append("</a>");

    final TextView donationlinks = (TextView) view.findViewById(R.id.donationlinks);
    donationlinks.setText(Html.fromHtml(donations.toString()));
    donationlinks.setMovementMethod(LinkMovementMethod.getInstance());

    Androzic application = Androzic.getApplication();
    if (application.isPaid) {
        view.findViewById(R.id.donations).setVisibility(View.GONE);
        view.findViewById(R.id.donationtext).setVisibility(View.GONE);
        donationlinks.setVisibility(View.GONE);
    }

    // license
    final SpannableString message = new SpannableString(
            Html.fromHtml(getString(R.string.app_eula).replace("/n", "<br/>")));
    Linkify.addLinks(message, Linkify.WEB_URLS);
    final TextView license = (TextView) view.findViewById(R.id.license);
    license.setText(message);
    license.setMovementMethod(LinkMovementMethod.getInstance());

    // credits
    String[] names = getResources().getStringArray(R.array.credit_names);
    String[] merits = getResources().getStringArray(R.array.credit_merits);

    StringBuilder credits = new StringBuilder();
    for (int i = 0; i < names.length; i++) {
        credits.append("<b>");
        credits.append(merits[i]);
        credits.append("</b> &mdash; ");
        credits.append(names[i]);
        credits.append("<br />");
    }

    final TextView creditlist = (TextView) view.findViewById(R.id.credits);
    creditlist.setText(Html.fromHtml(credits.toString()));

    // dedication
    final TextView dedicated = (TextView) view.findViewById(R.id.dedicated);
    dedicated.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            clicks = 1;
            dedicated.setVisibility(View.GONE);
            View photo = view.findViewById(R.id.photo);
            photo.setVisibility(View.VISIBLE);
            photo.setOnClickListener(redirect);
        }
    });
}

From source file:com.mycodehurts.rapidmath.app.AboutPage.java

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

    {//  w w w.  j av  a 2 s  .  co  m
        TextView link = (TextView) rootView.findViewById(R.id.visitkickstarter);
        String linkText = "<a href='https://www.kickstarter.com/projects/1373995643/rapidmath-educational-poster-for-rapid-mental-math'>Kickstarter Campaign</a> ";
        link.setText(Html.fromHtml(linkText));
        link.setMovementMethod(LinkMovementMethod.getInstance());
    }

    {
        TextView link = (TextView) rootView.findViewById(R.id.buyrapidmath);
        String linkText = "<a href='http://techessentials.myshopify.com/'>Buy Rapidmath Material</a> ";
        link.setText(Html.fromHtml(linkText));
        link.setMovementMethod(LinkMovementMethod.getInstance());
    }
    {
        TextView link = (TextView) rootView.findViewById(R.id.jhalaLink);
        String linkText = "<a href='https://plus.google.com/+VishalsinhJhala/posts'>Vishalsinh Jhala</a> ";
        link.setText(Html.fromHtml(linkText));
        link.setMovementMethod(LinkMovementMethod.getInstance());
    }
    {
        TextView link = (TextView) rootView.findViewById(R.id.githubLink);
        String linkText = "<a href='https://github.com/myCodeHurts/RapidMath'>Download Source</a> ";
        link.setText(Html.fromHtml(linkText));
        link.setMovementMethod(LinkMovementMethod.getInstance());
    }

    //TextView textView = (TextView) rootView.findViewById(R.id.section_label);
    //textView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)));

    //        Button btnStartTest = (Button)rootView.findViewById(R.id.btnStartTest);
    //        btnStartTest.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View view) {
    //
    //                RadioGroup chkSex = (RadioGroup)rootView.findViewById(R.id.testDifficultLevel);
    //
    //                if( chkSex.getCheckedRadioButtonId()==-1)
    //                {
    //
    //                }
    //                int iLevel = -1;
    //                if( chkSex.getCheckedRadioButtonId() == R.id.testEasy )
    //                    iLevel = 0;
    //                else if (chkSex.getCheckedRadioButtonId() == R.id.testMedium)
    //                    iLevel = 1;
    //                else if(chkSex.getCheckedRadioButtonId() == R.id.testDifficult)
    //                    iLevel = 2;
    //
    //                Intent intent = new Intent(rootView.getContext(), TestActivity.class);
    //                intent.putExtra("iLevel",iLevel);
    //                startActivity(intent);
    //            }
    //        });

    return rootView;
}

From source file:com.geomoby.geodeals.notification.CustomNotification.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //Hide Title Bar
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.geomoby_offer);

    Intent intent = getIntent();/*from   www  . jav  a 2  s  . c  om*/

    ArrayList<GeoMessage> geoMessage = intent.getParcelableArrayListExtra("GeoMessage");

    String title = geoMessage.get(0).title;
    String link = geoMessage.get(0).siteURL;
    String image_url = geoMessage.get(0).imageURL;
    String description = geoMessage.get(0).message;
    final double latitude = Double.valueOf(geoMessage.get(0).latitude);
    final double longitude = Double.valueOf(geoMessage.get(0).longitude);
    int notification_id = geoMessage.get(0).id;

    Button btnClose = (Button) findViewById(R.id.close);
    btnClose.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Perform action on click   
            CustomNotification.this.finish();
        }
    });

    Button btnNearest = (Button) findViewById(R.id.nearest);
    btnNearest.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            SharedPreferences settingsActivity = CustomNotification.this.getSharedPreferences("GeoMobyPrefs",
                    MODE_PRIVATE);
            final double myLatitude = Double.valueOf(settingsActivity.getString(SETTING_LAT, ""));
            final double myLongitude = Double.valueOf(settingsActivity.getString(SETTING_LNG, ""));

            Context context = CustomNotification.this;
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?f=d&saddr="
                    + myLatitude + "," + myLongitude + "&daddr=" + latitude + "," + longitude + "&dirflg=w"));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        }
    });

    Typeface font = Typeface.createFromAsset(getAssets(), "Bitter-Bold.otf");

    TextView tvTitle = (TextView) findViewById(R.id.title);
    tvTitle.setTypeface(font);
    tvTitle.setText(title);

    TextView tvDesc = (TextView) findViewById(R.id.description);
    tvDesc.setTypeface(font);
    tvDesc.setText(description);

    TextView tvLink = (TextView) findViewById(R.id.link);
    tvLink.setTypeface(font);
    String desc = "<a href=\"" + link + "\">Demo Link</a>";
    tvLink.setText(Html.fromHtml(desc));
    tvLink.setMovementMethod(LinkMovementMethod.getInstance());

    // Warning - Big bitmap images might create errors
    if (!image_url.equals(""))
        new DownloadImageTask((ImageView) findViewById(R.id.image)).execute(image_url);

    //Notify GeoMoby server that user has opened the notification
    //new ClickThroughAsyncTask(this).execute(notification_id);
}

From source file:de.janrenz.app.mediathek.MediathekActivity.java

protected AlertDialog getInfoDialog() {
    TextView tv = new TextView(this);
    //tv.setBackgroundColor(getResources().getColor(R.color.abs__bright_foreground_holo_dark)); 
    tv.setPadding(15, 15, 15, 15);/*from  www  . ja  v a  2s  .  c o m*/
    tv.setMovementMethod(new ScrollingMovementMethod());
    tv.setScrollBarStyle(1);
    tv.setText(Html.fromHtml(getString(R.string.infotext)));
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    builder.setTitle("Mediathek 1").setView(tv).setInverseBackgroundForced(true)//needed for old android version
            .setCancelable(false)
            // OK button
            .setPositiveButton(this.getResources().getString(R.string.changelog_ok_button),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
    // Show "More" button if we're only displaying a partial change log.
    builder.setNegativeButton(R.string.info_popup_changelog, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            if (cl != null)
                cl.getFullLogDialog().show();
        }
    });

    return builder.create();
}