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:org.wheelmap.android.fragment.LoginDialogFragment.java

@Override
public void onResume() {
    super.onResume();

    AlertDialog dialog = (AlertDialog) getDialog();
    Button button = dialog.getButton(AlertDialog.BUTTON_NEUTRAL);
    button.setOnClickListener(this);

    TextView forgot_password = (TextView) dialog.findViewById(R.id.login_forgot_password);
    String forgot_password_format = "<a href=\"http://wheelmap.org/users/password/new\">%s</a>";
    forgot_password.setText(Html.fromHtml(String.format(forgot_password_format, forgot_password.getText())));
    forgot_password.setLinksClickable(true);
    forgot_password.setMovementMethod(LinkMovementMethod.getInstance());

    TextView login2 = (TextView) dialog.findViewById(R.id.login_login_2);
    String login2_format = "<a href=\"" + getString(R.string.login_link_wheelmap) + "\">%s</a>";
    login2.setText(Html.fromHtml(String.format(login2_format, login2.getText())));
    login2.setLinksClickable(true);//from   w w  w  .j a va 2s.  c om
    login2.setMovementMethod(LinkMovementMethod.getInstance());

    mEmailText = (EditText) dialog.findViewById(R.id.login_email);
    mPasswordText = (EditText) dialog.findViewById(R.id.login_password);

    mEmailText.setText("");
    mPasswordText.setText("");

    mEmailText = (EditText) dialog.findViewById(R.id.login_email);
    mEmailText.setOnEditorActionListener(this);
    mPasswordText = (EditText) dialog.findViewById(R.id.login_password);
    mPasswordText.setOnEditorActionListener(this);

    load();

}

From source file:com.ubuntuone.android.files.fragment.SignUpFragment.java

private void setupViews(View content) {
    fullnameEditText = (EditTextPlus) content.findViewById(R.id.sso_fullname);

    emailErrorTextView = (TextViewPlus) content.findViewById(R.id.email_error);
    emailEditText = (EditTextPlus) content.findViewById(R.id.sso_username);

    passwordErrorTextView = (TextViewPlus) content.findViewById(R.id.password_error);
    passwordEditText = (EditTextPlus) content.findViewById(R.id.sso_password);

    passwordVisibleCheckBox = (CheckBoxPlus) content.findViewById(R.id.password_toggle);
    passwordVisibleCheckBox.setOnClickListener(this);

    captchaErrorTextView = (TextViewPlus) content.findViewById(R.id.captcha_error);

    signupButton = (Button) content.findViewById(R.id.sso_signup);
    signupButton.setOnClickListener(onButtonClickedListener);

    final TextView footer = (TextView) content.findViewById(R.id.signup_footer_tos);
    footer.setText(Html.fromHtml(getString(R.string.signup_footer_tos)));
    footer.setLinkTextColor(getResources().getColor(R.color.web_url));
    footer.setMovementMethod(LinkMovementMethod.getInstance());

    setupCaptchaImageView(content);//from   ww w. j a va  2s.  co  m
}

From source file:org.rssin.android.NavigationDrawerFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }/*  w  ww.j a  v  a  2s.c  om*/

    if (item.getItemId() == R.id.action_settings) {
        getCurrentItem().invokeActionSettings(mDrawerLayout.getContext());
        return true;
    }

    if (item.getItemId() == R.id.action_info) {
        TextView message = new TextView(getActivity());
        message.setText(Html.fromHtml(getString(R.string.app_info)));
        int padding = getResources().getDimensionPixelSize(R.dimen.listview_item_padding);
        message.setPadding(padding, padding, padding, 0);
        message.setMovementMethod(LinkMovementMethod.getInstance());

        AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.app_name))
                .setView(message).setPositiveButton(R.string.button_ok, null).setIcon(R.mipmap.ic_launcher)
                .show();

        View titleDivider = dialog.findViewById(getResources().getIdentifier("titleDivider", "id", "android"));
        if (titleDivider != null) {
            titleDivider.setBackgroundColor(getResources().getColor(R.color.abc_primary_text_material_light));
        }

        TextView title = (TextView) dialog
                .findViewById(getResources().getIdentifier("alertTitle", "id", "android"));
        if (title != null) {
            title.setTextColor(getResources().getColor(R.color.abc_primary_text_material_light));
        }
    }

    return super.onOptionsItemSelected(item);
}

From source file:in.animeshpathak.nextbus.NextBusMain.java

/**
 * Creates the Application Info dialog with clickable links.
 * // w  w  w. ja v  a  2  s  .c  o m
 * @throws UnsupportedEncodingException
 * @throws IOException
 */
private void showVersionInfoDialog() throws UnsupportedEncodingException, IOException {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle(getString(R.string.app_name) + " " + getString(R.string.version_name));

    AssetManager assetManager = getResources().getAssets();
    String versionInfoFile = getString(R.string.versioninfo_asset);
    InputStreamReader reader = new InputStreamReader(assetManager.open(versionInfoFile), "UTF-8");
    BufferedReader br = new BufferedReader(reader);
    StringBuffer sbuf = new StringBuffer();
    String line;
    while ((line = br.readLine()) != null) {
        sbuf.append(line);
        sbuf.append("\r\n");
    }

    final ScrollView scroll = new ScrollView(this);
    final TextView message = new TextView(this);
    final SpannableString sWlinks = new SpannableString(sbuf.toString());
    Linkify.addLinks(sWlinks, Linkify.WEB_URLS);
    message.setText(sWlinks);
    message.setMovementMethod(LinkMovementMethod.getInstance());
    message.setPadding(15, 15, 15, 15);
    scroll.addView(message);
    alertDialog.setView(scroll);
    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Ok", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // nothing to do, just dismiss dialog
        }
    });
    alertDialog.show();
}

From source file:com.gabm.fancyplaces.ui.MainWindow.java

protected void showAbout() {
    // Inflate the about message contents
    View messageView = getLayoutInflater().inflate(R.layout.about_window, null, false);

    TextView content = (TextView) messageView.findViewById(R.id.about_content);
    content.setText(Html.fromHtml(readText(R.raw.about_content)));
    content.setMovementMethod(LinkMovementMethod.getInstance());

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setIcon(R.drawable.ic_launcher);
    builder.setTitle(R.string.app_name);
    builder.setView(messageView);/*from  w ww .  j  a  v a  2s  .c om*/
    builder.create();
    builder.show();
}

From source file:com.manning.androidhacks.hack004.preference.AboutDialog.java

@Override
protected View onCreateDialogView() {
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView splashText = new TextView(mContext);
    String fmt = "Version %s<br />" + "<a href=\"http://manning.com/sessa\">MoreInfo</a>";
    try {// w w  w  .j a  v a  2  s  .  c o m
        String pkg = mContext.getPackageName();
        mVersionNumber = mContext.getPackageManager().getPackageInfo(pkg, 0).versionName;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    if (mVersionNumber != null) {
        String aboutMsg = String.format(fmt, mVersionNumber);
        splashText.setText(Html.fromHtml(aboutMsg));
        splashText.setMovementMethod(LinkMovementMethod.getInstance());
    }

    layout.addView(splashText);

    return layout;
}

From source file:com.google.android.apps.iosched.ui.gtv.GoogleTVSessionLivestreamActivity.java

public void handleNoLiveSessionsAvailable() {
    getSupportLoaderManager().initLoader(UPCOMING_SESSIONS_QUERY_ID, null, this);
    updateSessionViews(PROMO_VIDEO_URL, getString(R.string.missed_io_title),
            getString(R.string.missed_io_subtitle), UIUtils.CONFERENCE_HASHTAG);

    //Make link in abstract view clickable
    TextView abstractLinkTextView = (TextView) findViewById(R.id.session_abstract);
    abstractLinkTextView.setMovementMethod(new LinkMovementMethod());
}

From source file:com.ota.updates.fragments.AboutFragment.java

private void setupChangelog(View view, File file) {
    if (DEBUGGING) {
        Log.d(TAG, "Setting up changelog");
    }/*from w w  w  .jav a2 s.c  o m*/
    TextView changelogTV = (TextView) view.findViewById(R.id.changelog);
    Bypass bypass = new Bypass(mContext);
    String changelogString;
    try {
        changelogString = Utils.getFileContents(file);

    } catch (IOException e) {
        changelogString = getResources().getString(R.string.changelog_error);
        e.printStackTrace();
    }
    CharSequence changelogText = bypass.markdownToSpannable(changelogString);
    changelogTV.setText(changelogText);
    changelogTV.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:org.wheelmap.android.fragment.LoginFragment.java

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

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

    v.findViewById(R.id.button_login).setOnClickListener(new OnClickListener() {
        @Override/*  w  ww. ja v  a  2 s.com*/
        public void onClick(View v) {
            login();
        }
    });

    TextView forgot_password = (TextView) v.findViewById(R.id.login_forgot_password);
    String forgot_password_format = "<a href=\"http://wheelmap.org/users/password/new\">%s</a>";
    forgot_password.setText(Html.fromHtml(String.format(forgot_password_format, forgot_password.getText())));
    forgot_password.setLinksClickable(true);
    forgot_password.setMovementMethod(LinkMovementMethod.getInstance());

    TextView login2 = (TextView) v.findViewById(R.id.login_login_2);
    String login2_format = "<a href=\"" + getString(R.string.login_link_wheelmap) + "\">%s</a>";
    login2.setText(Html.fromHtml(String.format(login2_format, login2.getText())));
    login2.setLinksClickable(true);
    login2.setMovementMethod(LinkMovementMethod.getInstance());

    mEmailText = (EditText) v.findViewById(R.id.login_email);
    mPasswordText = (EditText) v.findViewById(R.id.login_password);
    mLoginRegister = (Button) v.findViewById(R.id.button_login_register);

    // mEmailText.setText("");
    //mPasswordText.setText("");

    if (!UtilsMisc.isTablet(getActivity().getApplicationContext())) {
        View scrollView = v.findViewById(R.id.scrollView);
        ViewGroup.LayoutParams params = scrollView.getLayoutParams();
        params.height = ViewGroup.LayoutParams.MATCH_PARENT;
        scrollView.setLayoutParams(params);
    }

    mLoginRegister.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Uri uriUrl = Uri.parse("http://wheelmap.org/en/oauth/register_osm");
            Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);
            startActivity(launchBrowser);
        }
    });

    return v;
}

From source file:com.murrayc.galaxyzoo.app.ZooFragment.java

private void showAbout() {
    final Activity activity = getActivity();
    final AlertDialog.Builder builder = new AlertDialog.Builder(activity);

    // Get the layout inflater
    final LayoutInflater inflater = activity.getLayoutInflater();

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    final View view = inflater.inflate(R.layout.about, null);
    builder.setView(view);//  ww  w .  j av a  2  s.  c  o m

    final TextView textView = (TextView) view.findViewById(R.id.textViewAbout);
    if (textView == null) {
        Log.error("showAbout: textView was null.");
        return;
    }

    //This voodoo makes the textviews' HTML links clickable:
    //See http://stackoverflow.com/questions/2734270/how-do-i-make-links-in-a-textview-clickable/20647011#20647011
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    final String versionText = String.format(getString(R.string.about_version_text_format),
            BuildConfig.VERSION_NAME);

    //The about dialog's text is split into multiple strings to make translation easier,
    //so we need to concatenate them here.
    //Note that we use getText(), not getString(),
    //so we don't lose the <a href=""> links.
    //Likewise, we use SpannableStringBuilder instead of StringBuilder,
    //because we lose the links when using StringBuilder.
    final SpannableStringBuilder strBuilder = new SpannableStringBuilder();
    final String PARAGRAPH_BREAK = "\n\n";
    strBuilder.append(versionText);
    strBuilder.append(PARAGRAPH_BREAK);
    strBuilder.append(getText(R.string.about_text1));
    strBuilder.append(PARAGRAPH_BREAK);
    strBuilder.append(getText(R.string.about_text2));
    strBuilder.append(PARAGRAPH_BREAK);
    strBuilder.append(getText(R.string.about_text3));
    strBuilder.append(PARAGRAPH_BREAK);
    strBuilder.append(getText(R.string.about_text3b));
    strBuilder.append(PARAGRAPH_BREAK);
    strBuilder.append(getText(R.string.about_text4));
    strBuilder.append(PARAGRAPH_BREAK);
    strBuilder.append(getText(R.string.about_text5));
    strBuilder.append(PARAGRAPH_BREAK);
    strBuilder.append(getText(R.string.about_text6));

    textView.setText(strBuilder);

    /* We used to put the version text into a separate TextView,
       but when the about text in textView is too long,
       the scroll never reaches this far.
       It does work when we add it to first regular textView.
     */
    /*
    final TextView textViewVersion = (TextView) view.findViewById(R.id.textViewVersion);
    if (textViewVersion != null) {
    textViewVersion.setText(versionText);
    }
    */

    final AlertDialog dialog = builder.create();
    dialog.setTitle(R.string.app_name);
    dialog.setIcon(R.mipmap.ic_launcher);

    dialog.show();
}