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:ua.juliazozulia.taskcollector.ui.main.MainActivity.java

private void setupViews() {

    View footer = getLayoutInflater().inflate(R.layout.drawer_footer, null);
    TextView textView = (TextView) footer.findViewById(R.id.footer);
    RelativeLayout footerLayout = (RelativeLayout) footer.findViewById(R.id.footer_layout);
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    setupTab();/*from  w  w w . j  av  a2 s . co  m*/
    setupToolbar();
    mDrawerResult = new DrawerBuilder().withActivity(this).withHeader(R.layout.drawer_header)
            .withToolbar(mToolbar)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName(R.string.all_issues).withIcon(R.drawable.ic_issues),
                    new PrimaryDrawerItem().withName(R.string.issues_on_map).withIcon(R.drawable.ic_map),
                    new DividerDrawerItem(), new PrimaryDrawerItem().withName(R.string.login))
            .withStickyFooterShadow(false).withStickyFooter(footerLayout).build();
}

From source file:com.nineducks.hereader.HackfulReaderActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    Dialog result = null;//  w  ww .ja v a2  s . com
    AlertDialog.Builder builder = null;
    switch (id) {
    case R.id.open_dialog:
        builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.open_dialog_title);
        builder.setItems(R.array.open_dialog_options, (OnClickListener) itemsController);
        builder.setCancelable(true);
        result = builder.create();
        break;
    case R.id.about_dialog:
        builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.about_dialog_title);
        ScrollView scroll = new ScrollView(this);
        TextView msg = new TextView(this);
        SpannableString s = new SpannableString(getString(R.string.about_dialog_text));
        Linkify.addLinks(s, Linkify.WEB_URLS);
        msg.setText(s);
        msg.setMovementMethod(LinkMovementMethod.getInstance());
        msg.setTextSize(16);
        msg.setPadding(15, 15, 15, 15);
        scroll.addView(msg);
        builder.setView(scroll);
        builder.setInverseBackgroundForced(true);
        result = builder.create();
        break;
    }
    return result;
}

From source file:org.aminb.id3r.fragment.AboutDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Get app version
    PackageManager pm = getActivity().getPackageManager();
    String packageName = getActivity().getPackageName();
    String versionName;// ww w  . j  av a2 s.co  m
    try {
        PackageInfo info = pm.getPackageInfo(packageName, 0);
        versionName = info.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        versionName = VERSION_UNAVAILABLE;
    }
    LayoutInflater layoutInflater = getActivity().getLayoutInflater();
    View rootView = layoutInflater.inflate(R.layout.dialog_custom, null);
    TextView aboutBodyView = (TextView) rootView.findViewById(R.id.body);
    aboutBodyView
            .setText(Html.fromHtml(getString(R.string.about_body, Calendar.getInstance().get(Calendar.YEAR))));
    aboutBodyView.setMovementMethod(new LinkMovementMethod());
    return new MaterialDialog.Builder(getActivity()).positiveText(android.R.string.ok)
            .positiveColorRes(R.color.accent)
            .title(Html.fromHtml(getString(R.string.app_name_and_version, versionName))).customView(rootView)
            .callback(new MaterialDialog.SimpleCallback() {
                @Override
                public void onPositive(MaterialDialog dialog) {
                }
            }).build();
}

From source file:com.CardMemorizer.android.MainNavigation.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mLayout = inflater.inflate(R.layout.about_page, container, false);
    TextView apacheText = (TextView) mLayout.findViewById(R.id.apache);
    apacheText.setText(//w  ww.  ja  v a  2 s.c o  m
            "Some parts of this software are protected by the Apache License, version 2.0. It can be found at "
                    + "http://www.apache.org/licenses/LICENSE-2.0.html");
    apacheText.setMovementMethod(LinkMovementMethod.getInstance());
    return mLayout;
}

From source file:com.hybris.mobile.activity.ProductDetailActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.product_detail);

    getActionBar().setHomeButtonEnabled(true);

    // Allow links in promotions label
    TextView promotionsTextView = (TextView) findViewById(R.id.textViewPromotion);
    promotionsTextView.setMovementMethod(LinkMovementMethod.getInstance());

    mLinks = new ArrayList<ProductOptionItem>();
    mVariantOptions = new ArrayList<String>();
    mAdapter = new ProductVariantAdapter(this, mLinks);
    mListView = (ListView) findViewById(R.id.list_variants);
    mListView.setAdapter(mAdapter);/*from w  ww .j  a  v a2  s. co m*/

    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> a, View v, int position, long l) {
            int selected = -1;
            mVariantOptions.clear();
            for (ProductOptionItem option : mProduct.getAllOptions()) {
                if (option.isSelectedOption()) {
                    continue;
                }
                if (option.getQualifier().equals(mLinks.get(position).getQualifier())) {
                    if (!mVariantOptions.contains(getVariantOption(option))) {
                        mVariantOptions.add(getVariantOption(option));
                        if (option.getValue().equals(mLinks.get(position).getValue())) {
                            selected = mVariantOptions.size() - 1;
                        }
                    }
                }
            }
            ProductVariantDialogFragment fragment = new ProductVariantDialogFragment(
                    mLinks.get(position).getQualifier(), mLinks.get(position).getName(), selected,
                    mVariantOptions.toArray(new String[0]), new DoneClickListener() {
                        @Override
                        public void onClick(String qualifier, int position) {
                            if (position < 0)
                                return;
                            for (ProductOptionItem option : mProduct.getAllOptions()) {
                                if (option.getQualifier().equals(qualifier)) {
                                    if (getVariantOption(option).equals(mVariantOptions.get(position))) {
                                        if (!StringUtils.equals(mProduct.getCode(), option.getCode())) {
                                            Intent intent = new Intent(ProductDetailActivity.this,
                                                    ProductDetailActivity.class);
                                            intent.putExtra(DataConstants.PRODUCT_CODE, option.getCode());
                                            startActivity(intent);
                                            finish();
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    });
            fragment.show(getFragmentManager(), "");
        }

    });
}

From source file:com.honu.giftwise.InfoActivity.java

protected void showLicenseInfo() {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle("License information");

    TextView tv = new TextView(this);
    tv.setText(Html.fromHtml(getString(R.string.isc_license)));
    tv.setMovementMethod(new ScrollingMovementMethod());
    tv.setPadding(12, 0, 12, 0);//from   ww w . j a  v a  2s  .  c  om
    alert.setView(tv);

    alert.setNegativeButton("Close", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
        }
    });
    alert.show();
}

From source file:com.sdrtouch.tools.DialogManager.java

private Dialog createDialog(final dialogs id) {
    switch (id) {
    case DIAG_ABOUT:
        final AlertDialog addd = new AlertDialog.Builder(getActivity()).setTitle(R.string.help)
                .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                    @Override/*w ww.j av a  2 s .co  m*/
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }).setMessage(Html.fromHtml(getString(R.string.help_info))).create();
        try {
            addd.setOnShowListener(new DialogInterface.OnShowListener() {
                @Override
                public void onShow(DialogInterface paramDialogInterface) {
                    try {
                        final TextView tv = (TextView) addd.getWindow().findViewById(android.R.id.message);
                        if (tv != null)
                            tv.setMovementMethod(LinkMovementMethod.getInstance());

                    } catch (Exception ignored) {
                    }
                }
            });
        } catch (Exception ignored) {
        }

        return addd;
    case DIAG_LICENSE:
        return new AlertDialog.Builder(getActivity()).setTitle("License")
                .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }).setMessage(readWholeStream(R.raw.license)).create();
    }
    return null;
}

From source file:org.jared.synodroid.ds.ui.HelpFragment.java

/**
 * Activity creation/*w  ww  .  j a  v a 2s  .com*/
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    try {
        if (((Synodroid) getActivity().getApplication()).DEBUG)
            Log.v(Synodroid.DS_TAG, "HelpFragment: Creating help fragment");
    } catch (Exception ex) {
        /*DO NOTHING*/}

    final FragmentActivity helpActivity = this.getActivity();
    View help = inflater.inflate(R.layout.help, null, false);
    Button helpBtn = (Button) help.findViewById(R.id.id_email);
    helpBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            try {
                final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                emailIntent.setType("plain/text");
                emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                        new String[] { "synodroid@gmail.com" });
                emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Synodroid Free - help");
                startActivity(emailIntent);
            } catch (Exception e) {
                AlertDialog.Builder builder = new AlertDialog.Builder(helpActivity);
                builder.setMessage(R.string.err_noemail);
                builder.setTitle(getString(R.string.connect_error_title)).setCancelable(false)
                        .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.cancel();
                            }
                        });
                AlertDialog errorDialog = builder.create();
                try {
                    errorDialog.show();
                } catch (BadTokenException ex) {
                    // Unable to show dialog probably because intent has been closed. Ignoring...
                }
            }
        }
    });
    Button gplusBtn = (Button) help.findViewById(R.id.id_gplus);
    gplusBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String url = "https://plus.google.com/111893484035545745539";
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            startActivity(i);
        }
    });

    TextView main_web = (TextView) help.findViewById(R.id.syno_main_web);
    main_web.setText(Html.fromHtml("<a href=\"http://www.synology.com\">www.synology.com</a>"));
    main_web.setMovementMethod(LinkMovementMethod.getInstance());

    TextView buy = (TextView) help.findViewById(R.id.syno_buy_web);
    buy.setText(Html.fromHtml(
            "<a href=\"http://www.synology.com/support/wheretobuy.php\">www.synology.com/support/wheretobuy.php</a>"));
    buy.setMovementMethod(LinkMovementMethod.getInstance());

    return help;
}

From source file:org.distantshoresmedia.activities.Main.java

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

    setContentView(R.layout.main);//ww  w  .  jav  a 2  s  .  c o m
    Main.context = getApplicationContext();

    KeyboardDatabaseHandler.initializeDatabaseIfNecessary(this.getApplicationContext());

    String html = getResources().getString(R.string.main_body);
    //html += "<p><i>Version: " + context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName + "</i></p>";
    Spanned content = Html.fromHtml(html);
    TextView description = (TextView) findViewById(R.id.main_description);
    description.setMovementMethod(LinkMovementMethod.getInstance());
    description.setText(content, BufferType.SPANNABLE);

    final Button setup1 = (Button) findViewById(R.id.main_setup_btn_configure_imes);
    setup1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startActivityForResult(new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS), 0);
        }
    });

    final Button setup2 = (Button) findViewById(R.id.main_setup_btn_set_ime);
    setup2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            mgr.showInputMethodPicker();
        }
    });

    final Activity that = this;

    final Button setup4 = (Button) findViewById(R.id.main_setup_btn_input_lang);
    setup4.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startActivityForResult(new Intent(that, InputLanguageSelection.class), 0);
        }
    });

    final Button setup5 = (Button) findViewById(R.id.main_setup_btn_update_keyboards);
    setup5.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            updateKeyboards();
        }
    });

    final Button setup6 = (Button) findViewById(R.id.main_setup_btn_keyboard_sharing);
    setup6.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            sharePressed();

        }
    });
    final Button setup7 = (Button) findViewById(R.id.main_setup_btn_bug_reporting);
    setup7.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            reportBugPressed();
        }
    });
}

From source file:org.thbz.hanguldrill.HelpDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity activity = getActivity();/*from  w  w  w  .  j  ava 2 s .co m*/

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);

    // Initialiser le texte de l'aide  partir d'un fichier inclu dans l'APK
    StringBuilder htmlHelpText = new StringBuilder();
    try {
        BufferedReader in = new BufferedReader(
                new InputStreamReader(activity.getAssets().open("help_contents.html")));
        String line;
        int state = 0;
        while ((line = in.readLine()) != null) {
            if (line.contains("<!-- START APP CONTENTS -->"))
                state = 1;
            else if (state == 1) {
                if (line.contains("<!-- END APP CONTENTS -->"))
                    state = 2;
                else
                    htmlHelpText.append(line);
            }
        }
    } catch (IOException exc) {
        htmlHelpText.setLength(0);
        htmlHelpText.append("Help is not available (").append(exc.getMessage()).append(")");
    }

    LayoutInflater inflater = activity.getLayoutInflater();
    View dialogView = inflater.inflate(R.layout.dialog_help, null);
    TextView helpTextView = (TextView) dialogView.findViewById(R.id.dialog_help_text);
    helpTextView.setText(Html.fromHtml(htmlHelpText.toString()));

    // Allow for external hyperlinks in the HTML text
    helpTextView.setMovementMethod(LinkMovementMethod.getInstance());

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    builder.setView(dialogView)
            // Add action buttons
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                }
            });

    return builder.create();
}