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.example.onenoteservicecreatepageexample.ResultsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_results);
    // Show the Up button in the action bar.
    setupActionBar();//w w w.j a v a2 s.c  o m

    //Get messages from the intent
    Intent intent = getIntent();
    String clientUrl = intent.getStringExtra(Constants.CLIENT_URL).replaceAll(
            //This regular expression adds curly braces before and after the section identifier and page identifier values in the client URL
            "=([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})&", "={$1}&");
    TextView clientLinkView = (TextView) findViewById(R.id.lbl_clientLink);
    clientLinkView.setText(Html.fromHtml("<a href = \'" + clientUrl + "\'>" + clientUrl + "</a>"));
    clientLinkView.setMovementMethod(LinkMovementMethod.getInstance());
    //Set the messages
    ((TextView) findViewById(R.id.lbl_Response)).setText(intent.getStringExtra(Constants.RESPONSE));
    ((TextView) findViewById(R.id.lbl_webLink)).setText(intent.getStringExtra(Constants.WEB_URL));
}

From source file:com.grokkingandroid.sampleapp.samples.about.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Resources res = getResources();
    if (getArguments() == null) {
        throw new IllegalStateException("Arguments bundle must not be empty");
    }//from  w  ww  . j  ava 2  s  .c o  m
    int[] resIds = getArguments().getIntArray(KEY_RESOURCE_IDS);
    getDialog().setTitle(res.getString(R.string.about));
    View view = inflater.inflate(R.layout.fragment_about, container, false);
    ViewGroup libParent = (ViewGroup) view.findViewById(R.id.about_container);

    String[] libTitles = null;
    String[] libDescriptions = null;
    if (resIds[0] != -1) {
        libTitles = res.getStringArray(resIds[0]);
        libDescriptions = res.getStringArray(resIds[1]);
    }
    if (getArguments().getBoolean(KEY_ADD_DEFAULT_LIBS, true)) {
        if (resIds[0] == -1) {
            libTitles = res.getStringArray(R.array.grokkingandroidsample_about_titles);
            libDescriptions = res.getStringArray(R.array.grokkingandroidsample_about_contents);
        } else {
            String[] defaultTitles = res.getStringArray(R.array.grokkingandroidsample_about_titles);
            String[] target = new String[defaultTitles.length + libTitles.length];
            System.arraycopy(libTitles, 0, target, 0, libTitles.length);
            System.arraycopy(defaultTitles, 0, target, libTitles.length, defaultTitles.length);
            libTitles = target;
            String[] defaultDescriptions = res.getStringArray(R.array.grokkingandroidsample_about_contents);
            target = new String[defaultDescriptions.length + libTitles.length];
            System.arraycopy(libDescriptions, 0, target, 0, libDescriptions.length);
            System.arraycopy(defaultDescriptions, 0, target, libDescriptions.length,
                    defaultDescriptions.length);
            libDescriptions = target;
        }
    }
    String libraryPlural = res.getQuantityString(R.plurals.plural_libraries, libTitles.length);
    String appTitle = res.getString(resIds[3]);
    String copyrightYear = res.getString(resIds[4]);
    String repositoryLink = res.getString(resIds[5]);
    String aboutText = res.getString(resIds[2], appTitle, copyrightYear, repositoryLink, libraryPlural);
    Spanned spannedAboutText = Html.fromHtml(aboutText);
    TextView aboutTv = (TextView) libParent.findViewById(R.id.about_text);
    aboutTv.setText(spannedAboutText);
    aboutTv.setMovementMethod(LinkMovementMethod.getInstance());

    if (libTitles != null) {
        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.syncedsynapse.kore2.ui.hosts.AddHostFragmentWelcome.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (getView() == null)
        return;//ww w .j a  v a  2s  .  c  o  m

    TextView message = (TextView) getView().findViewById(R.id.add_host_message);
    message.setText(Html.fromHtml(getString(R.string.wizard_welcome_message)));
    message.setMovementMethod(LinkMovementMethod.getInstance());

    // Next button
    Button next = (Button) getView().findViewById(R.id.next);
    next.setText(R.string.next);
    next.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            listener.onAddHostWelcomeNext();
        }
    });

    // Previous button
    Button previous = (Button) getView().findViewById(R.id.previous);
    previous.setText(android.R.string.cancel);
    previous.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            listener.onAddHostWelcomeCancel();
        }
    });
}

From source file:com.tortel.deploytrack.fragments.AboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context wrappedContext = new ContextThemeWrapper(getActivity(), R.style.Theme_DeployThemeLight);

    MaterialDialog.Builder builder = new MaterialDialog.Builder(wrappedContext);

    LayoutInflater inflater = getActivity().getLayoutInflater().cloneInContext(wrappedContext);
    View view = inflater.inflate(R.layout.about, null);
    TextView text = (TextView) view.findViewById(R.id.about_view);

    text.setText(Html.fromHtml(readRawTextFile(R.raw.about)));
    Linkify.addLinks(text, Linkify.ALL);
    text.setMovementMethod(LinkMovementMethod.getInstance());

    builder.customView(view, false);/* w w  w .j  av a2  s .c o m*/
    builder.title(R.string.app_name);
    builder.positiveText(R.string.close);

    return builder.build();
}

From source file:me.sudar.zxingorient.demo.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//ww w.  j a va2s  . c  o  m

    resultTextView = (TextView) findViewById(R.id.result_text_view);
    shareEditText = (EditText) findViewById(R.id.encodeEditText);
    findViewById(R.id.button_1).setOnClickListener(this);
    findViewById(R.id.button_2).setOnClickListener(this);
    findViewById(R.id.button_3).setOnClickListener(this);
    findViewById(R.id.button_4).setOnClickListener(this);
    findViewById(R.id.button_5).setOnClickListener(this);

    TextView textView = (TextView) findViewById(R.id.github_link);
    textView.setClickable(true);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    String text = "Check out the <a href='https://github.com/SudarAbisheck/ZXing-Orient'>Github Repo !!</a>";
    textView.setText(Html.fromHtml(text));

    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
        requestCameraPermission();
    }

}

From source file:com.dev.campus.event.EventFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_event, container, false);
    ((TextView) rootView.findViewById(R.id.event_view_title)).setText(mEvent.getTitle());
    ((TextView) rootView.findViewById(R.id.event_view_category)).setText(mEvent.getCategory());
    ((TextView) rootView.findViewById(R.id.event_view_date)).setText(mEvent.getStringDate());

    TextView detailsView = (TextView) rootView.findViewById(R.id.event_view_details);
    detailsView.setText(Html.fromHtml(mEvent.getDetails()));
    Linkify.addLinks(detailsView, Linkify.EMAIL_ADDRESSES);
    detailsView.setMovementMethod(LinkMovementMethod.getInstance());
    return rootView;
}

From source file:org.yasik.android.utils.conditions.RateAppDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    setCancelable(true);/*from  w  w w.  j  a va  2  s.c o  m*/
    // Inflate and build the dialog view.
    LayoutInflater inflater = getActivity().getLayoutInflater();
    LinearLayout dialogLayout = (LinearLayout) inflater.inflate(R.layout.rateapp_dialog_fragment, null);
    TextView textView = (TextView) dialogLayout.findViewById(R.id.rateapp_dialog_text);
    textView.setText(Html.fromHtml(getString(R.string.rateapp_dialog_text)));
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setSingleLine(false);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(dialogLayout).setTitle(R.string.rateapp_dialog_title)
            .setPositiveButton(R.string.rateapp_btn_title_rateme, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mListener.onDialogRateNowClick(RateAppDialogFragment.this);
                }
            }).setNeutralButton(R.string.rateapp_btn_title_remind, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mListener.onDialogRemindClick(RateAppDialogFragment.this);
                }
            }).setNegativeButton(R.string.rateapp_btn_title_cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mListener.onDialogCancelClick(RateAppDialogFragment.this);
                }
            }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    mListener.onDialogCancelClick(RateAppDialogFragment.this);
                }
            });
    return builder.create();
}

From source file:com.syncedsynapse.kore2.ui.hosts.AddHostFragmentFinish.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (getView() == null)
        return;/* w w w  .  ja  v a 2s  .  co  m*/

    TextView message = (TextView) getView().findViewById(R.id.done_message);
    message.setText(Html.fromHtml(getString(R.string.wizard_done_message)));
    message.setMovementMethod(LinkMovementMethod.getInstance());

    // Finish button
    Button next = (Button) getView().findViewById(R.id.next);
    next.setText(R.string.finish);
    next.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            listener.onAddHostFinish();
        }
    });

    // Previous button
    Button previous = (Button) getView().findViewById(R.id.previous);
    previous.setText(null);
    previous.setEnabled(false);

    // Start the syncing process
    Intent syncIntent = new Intent(this.getActivity(), LibrarySyncService.class);
    syncIntent.putExtra(LibrarySyncService.SYNC_ALL_MOVIES, true);
    syncIntent.putExtra(LibrarySyncService.SYNC_ALL_TVSHOWS, true);
    syncIntent.putExtra(LibrarySyncService.SYNC_ALL_MUSIC, true);
    syncIntent.putExtra(LibrarySyncService.SYNC_ALL_MUSIC_VIDEOS, true);
    getActivity().startService(syncIntent);

    //        InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    //        imm.hideSoftInputFromWindow(getActivity()
    //                        .getWindow()
    //                        .getDecorView()
    //                        .getRootView()
    //                        .getWindowToken(), 0);
}

From source file:com.renard.ocr.help.LicenseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_license);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    TextView leptonica = (TextView) findViewById(R.id.textView_leptonica);
    TextView tesseract = (TextView) findViewById(R.id.textView_tesseract);
    TextView hocr2pdf = (TextView) findViewById(R.id.textView_hocr2pdf);
    leptonica.setMovementMethod(new LinkMovementMethod());
    tesseract.setMovementMethod(new LinkMovementMethod());
    hocr2pdf.setMovementMethod(new LinkMovementMethod());
}

From source file:com.frostwire.android.gui.fragments.AboutFragment.java

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

    TextView title = (TextView) view.findViewById(R.id.fragment_about_title);
    title.setText("FrostWire v" + Constants.FROSTWIRE_VERSION_STRING + " build " + Constants.FROSTWIRE_BUILD);

    TextView content = (TextView) view.findViewById(R.id.fragment_about_content);
    content.setText(Html.fromHtml(getAboutText()));
    content.setMovementMethod(LinkMovementMethod.getInstance());

    if (biller == null) {
        biller = BillerFactory.getInstance(getActivity());
    }//  w ww  .j  av a2s .c om

    DonationSkus skus = BillerFactory.getDonationSkus();

    setupDonateButton(view, R.id.fragment_about_button_donate1, skus.getSku(DonationSkuType.SKU_01_DOLLARS),
            "https://gumroad.com/l/pH", biller);
    setupDonateButton(view, R.id.fragment_about_button_donate2, skus.getSku(DonationSkuType.SKU_05_DOLLARS),
            "https://gumroad.com/l/oox", biller);
    setupDonateButton(view, R.id.fragment_about_button_donate3, skus.getSku(DonationSkuType.SKU_10_DOLLARS),
            "https://gumroad.com/l/rPl", biller);
    setupDonateButton(view, R.id.fragment_about_button_donate4, skus.getSku(DonationSkuType.SKU_25_DOLLARS),
            "https://gumroad.com/l/XQW", biller);

    return view;
}