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.nextgis.mobile.activity.AboutActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);
    setToolbar(R.id.main_toolbar);//from www.  j  av a  2s  . c  om

    mViewPager = (ViewPager) findViewById(com.nextgis.maplibui.R.id.viewPager);
    PagerAdapter adapter = new TabsAdapter(getSupportFragmentManager());
    mViewPager.setAdapter(adapter);
    mViewPager.addOnPageChangeListener(this);

    TabLayout tabLayout = (TabLayout) findViewById(com.nextgis.maplibui.R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    TextView txtCopyrightText = (TextView) findViewById(R.id.copyright);
    txtCopyrightText.setText(Html.fromHtml(getString(R.string.copyright)));
    txtCopyrightText.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:org.xbmc.kore.ui.sections.hosts.AddHostFragmentFinish.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (getView() == null)
        return;/* www .j  a va  2s  . c o  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);

    // Check if PVR is enabled for the current host
    HostManager hostManager = HostManager.getInstance(getActivity());
    if (hostManager.getHostInfo() != null) {
        checkPVREnabledAndSetMenuItems(getActivity(), new Handler());
    }

    // 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:edu.usf.cutr.opentripplanner.android.AboutActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.about);//  w  w w  .j a v a2 s. co  m
    TextView description = (TextView) findViewById(R.id.appDescription);
    TextView acknowledgements = (TextView) findViewById(R.id.acknowledgements);
    TextView license = (TextView) findViewById(R.id.license);
    Button playServicesButton = (Button) findViewById(R.id.playServicesButton);
    description.setMovementMethod(LinkMovementMethod.getInstance());
    acknowledgements.setMovementMethod(LinkMovementMethod.getInstance());
    license.setMovementMethod(LinkMovementMethod.getInstance());
    playServicesButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(AboutActivity.this, AboutPlayServicesActivity.class);
            startActivity(intent);
        }
    });
}

From source file:org.xbmc.kore.ui.hosts.AddHostFragmentFinish.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (getView() == null)
        return;//from   w ww. j  a v  a  2  s . c o  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);

    // Check if PVR is enabled for the current host
    HostManager hostManager = HostManager.getInstance(getActivity());
    if (hostManager.getHostInfo() != null) {
        AddHostFragmentFinish.checkPVREnabledAndSetMenuItems(getActivity(), new Handler());
        String prefKey = Settings.KEY_PREF_CHECKED_PVR_ENABLED
                + String.valueOf(hostManager.getHostInfo().getId());
        PreferenceManager.getDefaultSharedPreferences(getActivity()).edit().putBoolean(prefKey, true).apply();
    }

    // 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.github.michalbednarski.intentslab.browser.RegisteredReceiverInfoFragment.java

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

    // Find views: header, icon, component name and description
    TextView titleTextView = (TextView) v.findViewById(R.id.title);
    TextView componentTextView = (TextView) v.findViewById(R.id.component);
    ImageView iconView = (ImageView) v.findViewById(R.id.icon);
    TextView descriptionTextView = (TextView) v.findViewById(R.id.description);
    descriptionTextView.setMovementMethod(LinkMovementMethod.getInstance());

    // Fill header
    titleTextView.setText(R.string.registered_receiver);
    componentTextView.setText(mReceiverInfo.processName);
    /*mIconView.setImageDrawable(
        mExtendedComponentInfo.systemComponentInfo.loadIcon(getActivity().getPackageManager())
    );*///from   w  w w.  ja va2 s .  c  o m
    iconView.setImageDrawable(null); // TODO

    // Description text
    FormattedTextBuilder text = new FormattedTextBuilder();

    // Description: permission
    boolean hasOverallPermission = false;
    String permission = null;
    try {
        permission = mReceiverInfo.getOverallPermission();
        hasOverallPermission = true;
    } catch (RegisteredReceiverInfo.MixedPermissionsException ignored) {
    }
    if (permission != null) {
        text.appendValue(getString(R.string.permission_required_title), permission, true,
                FormattedTextBuilder.ValueSemantic.PERMISSION);
    }

    // Description: <intent-filter>'s
    text.appendHeader(getString(R.string.intent_filters));
    IntentFilter[] intentFilters = mReceiverInfo.intentFilters;
    for (int i = 0, j = intentFilters.length; i < j; i++) {
        IntentFilter filter = intentFilters[i];
        boolean hasSpecificPermission = !hasOverallPermission && mReceiverInfo.filterPermissions[i] != null;
        if (hasSpecificPermission) {
            text.appendColoured( // TODO: link
                    "\n\n<!-- " + getString(R.string.permission_required_title) + ": "
                            + mReceiverInfo.filterPermissions[i] + " -->",
                    getResources().getColor(R.color.xml_comment));
        }
        text.appendFormattedText(ComponentInfoFragment.dumpIntentFilter(filter, getResources(), true));
        if (hasSpecificPermission) {
            text.appendRaw("\n");
        }
    }

    // Put text in TextView
    descriptionTextView.setText(text.getText());

    // Go to intent editor button
    v.findViewById(R.id.go_to_intent_editor).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (getArguments().getBoolean(ComponentInfoFragment.ARG_LAUNCHED_FROM_INTENT_EDITOR, false)) {
                getActivity().finish();
                return;
            }
            startActivity(new Intent(getActivity(), IntentEditorActivity.class)
                    .putExtra(IntentEditorActivity.EXTRA_INTENT, new Intent())
                    .putExtra(IntentEditorActivity.EXTRA_COMPONENT_TYPE, IntentEditorConstants.BROADCAST)
                    .putExtra(IntentEditorActivity.EXTRA_INTENT_FILTERS, mReceiverInfo.intentFilters));
        }
    });

    // Receive broadcast button
    View receiveBroadcastButton = v.findViewById(R.id.receive_broadcast);
    receiveBroadcastButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ReceiveBroadcastService.startReceiving(getActivity(), mReceiverInfo.intentFilters, false);
        }
    });
    receiveBroadcastButton.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            ReceiveBroadcastService.startReceiving(getActivity(), mReceiverInfo.intentFilters, true);
            return true;
        }
    });
    receiveBroadcastButton.setVisibility(View.VISIBLE);
    receiveBroadcastButton.setEnabled(true);

    return v;
}

From source file:hku.fyp14017.blencode.ui.dialogs.TermsOfUseDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle bundle) {
    Bundle fragmentDialogArguments = getArguments();
    boolean acceptTermsOfUse = false;
    if (fragmentDialogArguments != null) {
        acceptTermsOfUse = fragmentDialogArguments.getBoolean(DIALOG_ARGUMENT_TERMS_OF_USE_ACCEPT, false);
    }/*from ww w. j  av a 2 s .  c o m*/

    View view = LayoutInflater.from(getActivity()).inflate(hku.fyp14017.blencode.R.layout.dialog_terms_of_use,
            null);

    final CheckBox checkBoxTermsOfUseAcceptedPermanently = (CheckBox) view
            .findViewById(hku.fyp14017.blencode.R.id.dialog_terms_of_use_check_box_agree_permanently);

    TextView termsOfUseUrlTextView = (TextView) view
            .findViewById(hku.fyp14017.blencode.R.id.dialog_terms_of_use_text_view_url);
    termsOfUseUrlTextView.setMovementMethod(LinkMovementMethod.getInstance());

    String termsOfUseUrl = getString(hku.fyp14017.blencode.R.string.terms_of_use_link_template,
            Constants.CATROBAT_TERMS_OF_USE_URL,
            getString(hku.fyp14017.blencode.R.string.dialog_terms_of_use_link_text));

    termsOfUseUrlTextView.setText(Html.fromHtml(termsOfUseUrl));

    AlertDialog.Builder termsOfUseDialogBuilder = new AlertDialog.Builder(getActivity()).setView(view)
            .setTitle(hku.fyp14017.blencode.R.string.dialog_terms_of_use_title);

    if (!acceptTermsOfUse) {
        termsOfUseDialogBuilder.setNeutralButton(hku.fyp14017.blencode.R.string.ok,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
    } else {
        termsOfUseDialogBuilder.setNegativeButton(
                hku.fyp14017.blencode.R.string.dialog_terms_of_use_do_not_agree,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        getActivity().finish();
                        dialog.dismiss();
                    }
                });
        termsOfUseDialogBuilder.setPositiveButton(hku.fyp14017.blencode.R.string.dialog_terms_of_use_agree,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        if (checkBoxTermsOfUseAcceptedPermanently.isChecked()) {
                            SettingsActivity.setTermsOfServiceAgreedPermanently(getActivity(), true);
                        }
                        dialog.dismiss();
                        DroneInitializer droneInitializer = ((PreStageActivity) getActivity())
                                .getDroneInitializer();
                        if (droneInitializer != null) {
                            droneInitializer.initialiseDrone();
                        }
                    }
                });
        termsOfUseDialogBuilder.setOnKeyListener(new OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                Log.d(TAG, "prevent canceling the dialog with back button");
                return true;
            }
        });

        checkBoxTermsOfUseAcceptedPermanently.setVisibility(CheckBox.VISIBLE);
        checkBoxTermsOfUseAcceptedPermanently
                .setText(hku.fyp14017.blencode.R.string.dialog_terms_of_use_agree_permanent);
        termsOfUseDialogBuilder.setCancelable(false);
    }

    AlertDialog termsOfUseDialog = termsOfUseDialogBuilder.create();
    if (!acceptTermsOfUse) {
        termsOfUseDialog.setCanceledOnTouchOutside(true);
    } else {
        termsOfUseDialog.setCancelable(false);
        termsOfUseDialog.setCanceledOnTouchOutside(false);
    }

    return termsOfUseDialog;
}

From source file:com.android.talkbacktests.testsession.TestSessionFragment.java

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

    final BaseTestContent content = TestController.getInstance().getSessionById(mSessionId)
            .getTestContent(mContentIndex);

    final TextView description = (TextView) (view.findViewById(R.id.contentContainer)
            .findViewById(R.id.description));
    description.setText(Html.fromHtml(content.getDescription()));
    description.setMovementMethod(LinkMovementMethod.getInstance());

    final TextView subtitle = (TextView) (view.findViewById(R.id.contentContainer).findViewById(R.id.title));
    subtitle.setText(content.getSubtitle());

    final Button previous = (Button) view.findViewById(R.id.previous);
    previous.setOnClickListener(this);

    final Button next = (Button) view.findViewById(R.id.next);
    next.setOnClickListener(this);

    assignButtonText(previous, next);/*w  w  w . j  a va  2 s .  c om*/

    final ViewGroup contentArea = (ViewGroup) view.findViewById(R.id.content_area);
    contentArea.addView(content.getView(inflater, contentArea, getContext()));

    return view;
}

From source file:se.chalmers.dat255.group22.escape.MainActivity.java

private void showAboutDialog() {
    if (aboutDialog == null) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getString(R.string.about_dialog_title));
        builder.setIcon(R.drawable.ic_launcher);

        View dialogView = getLayoutInflater().inflate(R.layout.about_dialog, null, false);

        // Interprets html link tags correctly and makes links clickable
        TextView repoLink = (TextView) dialogView.findViewById(R.id.about_dialog_repo);
        repoLink.setMovementMethod(LinkMovementMethod.getInstance());

        TextView licenseLink = (TextView) dialogView.findViewById(R.id.about_dialog_license);
        licenseLink.setMovementMethod(LinkMovementMethod.getInstance());

        builder.setView(dialogView);//ww  w  . j a  va  2 s . co  m

        aboutDialog = builder.create();
    }

    // Brings up the dialog
    aboutDialog.show();

}

From source file:com.google.samples.apps.abelana.LoginActivity.java

private void displayDialog() {
    // Build the about body view and append the link to see OSS licenses
    SpannableStringBuilder aboutBody = new SpannableStringBuilder();
    aboutBody.append(Html.fromHtml(getString(R.string.splash_dialog_body)));

    LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.dialog_about, null);
    aboutBodyView.setText(aboutBody);/*from   www .j  av  a2  s  .co  m*/
    aboutBodyView.setMovementMethod(new LinkMovementMethod());
    new AlertDialog.Builder(this).setTitle(getString(R.string.splash_dialog_title)).setView(aboutBodyView)
            .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).show();
}

From source file:com.robomorphine.fragment.AboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View view = inflater.inflate(R.layout.fragment_about, null);

    TextView version = (TextView) view.findViewById(R.id.version);
    TextView author = (TextView) view.findViewById(R.id.author);
    TextView project = (TextView) view.findViewById(R.id.project);
    TextView license = (TextView) view.findViewById(R.id.license);
    TextView repo = (TextView) view.findViewById(R.id.repo);

    author.setMovementMethod(LinkMovementMethod.getInstance());
    project.setMovementMethod(LinkMovementMethod.getInstance());
    license.setMovementMethod(LinkMovementMethod.getInstance());
    repo.setMovementMethod(LinkMovementMethod.getInstance());

    version.setText(getVersion());/*  w w  w . ja v a  2 s  .co  m*/
    author.setText(linkify(R.string.author, R.string.author_link));
    project.setText(linkify(R.string.project, R.string.project_link));
    license.setText(linkify(R.string.license, R.string.license_link));
    repo.setText(linkify(R.string.repo, R.string.repo_link));

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.about);
    builder.setView(view);
    builder.setCancelable(true);
    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dismiss();
        }
    });

    return builder.create();
}