Example usage for android.text.method LinkMovementMethod getInstance

List of usage examples for android.text.method LinkMovementMethod getInstance

Introduction

In this page you can find the example usage for android.text.method LinkMovementMethod getInstance.

Prototype

public static MovementMethod getInstance() 

Source Link

Usage

From source file:com.madgag.agit.CloneLauncherActivity.java

private void displayHelp(CharSequence message) {
    cloneReadinessMessageView.setVisibility(message == null ? INVISIBLE : VISIBLE);
    if (message != null) {
        Editable spana = new SpannableStringBuilder(message);
        ClickableText.addLinks(spana, BOLD_LINK_STYLE, new ClickableText.Listener() {
            public void onClick(String command, View widget) {
                if (command.equals("specify_target_dir")) {
                    useDefaultGitDirLocationButton.setChecked(false);
                    gitDirEditText.requestFocus();
                    setCursorToEnd(gitDirEditText);
                } else if (command.equals("view_existing_repo")) {
                    startActivity(manageRepoIntent(existingRepoGitDir()));
                } else if (command.equals("view_ssh_instructions")) {
                    startActivity(new Intent(CloneLauncherActivity.this, AboutUsingSshActivity.class));
                } else if (command.equals("suggest_repo")) {
                    startActivityForResult(new GitIntentBuilder("repo.SUGGEST").toIntent(), 0);
                }//from   w  ww .  j  a  v a  2 s .c  om
            }
        });
        cloneReadinessMessageView.setText(spana);
        cloneReadinessMessageView.setMovementMethod(LinkMovementMethod.getInstance());
    }
}

From source file:com.liushengfan.test.customerviewgroup.view.PagerSlidingTabStrip.java

private void addTextTab(final int position, SpannableString title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);//w  w w  .j  a v a 2  s.  c o  m
    tab.setMovementMethod(LinkMovementMethod.getInstance());
    tab.setGravity(Gravity.CENTER);
    tab.setMaxLines(2);
    tab.setSingleLine(false);
    addTab(position, tab);
}

From source file:com.dwdesign.tweetings.fragment.UserListDetailsFragment.java

public void changeUserList(final long account_id, final UserList user_list) {
    if (user_list == null || getActivity() == null || !isMyActivatedAccount(getActivity(), account_id))
        return;/*from   w  w w .  j  ava  2 s . c  o m*/
    getLoaderManager().destroyLoader(0);
    final User user = user_list.getUser();
    if (user == null)
        return;
    final boolean is_my_activated_account = isMyActivatedAccount(getActivity(), user_list.getId());
    mErrorRetryContainer.setVisibility(View.GONE);
    mAccountId = account_id;
    mUserListId = user_list.getId();
    mUserName = user.getName();
    mUserId = user.getId();
    mUserScreenName = user.getScreenName();
    mListName = user_list.getName();
    mListSlug = user_list.getSlug();

    final boolean is_multiple_account_enabled = getActivatedAccountIds(getActivity()).length > 1;

    mListView.setBackgroundResource(is_multiple_account_enabled ? R.drawable.ic_label_account_nopadding : 0);
    if (is_multiple_account_enabled) {
        final Drawable d = mListView.getBackground();
        if (d != null) {
            d.mutate().setColorFilter(getAccountColor(getActivity(), account_id), PorterDuff.Mode.MULTIPLY);
            mListView.invalidate();
        }
    }

    mListNameView.setText(mListName);
    mUserNameView.setText(mDisplayName ? mUserName : mUserScreenName);
    final String description = user_list.getDescription();
    mDescriptionContainer
            .setVisibility(is_my_activated_account || !isNullOrEmpty(description) ? View.VISIBLE : View.GONE);
    mDescriptionContainer.setOnLongClickListener(this);
    mDescriptionView.setText(description);
    final TwidereLinkify linkify = new TwidereLinkify(mDescriptionView);
    linkify.setOnLinkClickListener(this);
    linkify.addAllLinks();
    mDescriptionView.setMovementMethod(LinkMovementMethod.getInstance());
    final String profile_image_url_string = parseString(user.getProfileImageURL());
    final boolean hires_profile_image = getResources().getBoolean(R.bool.hires_profile_image);
    mProfileImageLoader.displayProfileImage(mProfileImageView,
            hires_profile_image ? getBiggerTwitterProfileImage(profile_image_url_string)
                    : profile_image_url_string);
    mUserList = user_list;
    //if (mUserId == mAccountId) {
    mFollowMoreButton.setText(R.string.more);
    mFollowMoreButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.expander_open_holo, 0);
    //} else {
    //   mFollowMoreButton.setText(user_list.isFollowing() ? R.string.unfollow : R.string.follow);
    //   mFollowMoreButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
    //}
    mAdapter.notifyDataSetChanged();
}

From source file:org.odk.collect.android.widgets.QuestionWidget.java

private TextView createHelpText(FormEntryPrompt prompt) {
    TextView helpText = new TextView(getContext());
    String s = prompt.getHelpText();

    if (s != null && !s.equals("")) {
        helpText.setId(ViewIds.generateViewId());
        helpText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, questionFontsize - 3);
        //noinspection ResourceType
        helpText.setPadding(0, -5, 0, 7);
        // wrap to the widget of view
        helpText.setHorizontallyScrolling(false);
        helpText.setTypeface(null, Typeface.ITALIC);
        helpText.setText(TextUtils.textToHtml(s));
        helpText.setTextColor(ContextCompat.getColor(getContext(), R.color.primaryTextColor));
        helpText.setMovementMethod(LinkMovementMethod.getInstance());
        return helpText;
    } else {/*  w w w. j a v  a2  s  .  c om*/
        helpText.setVisibility(View.GONE);
        return helpText;
    }
}

From source file:ru.orangesoftware.financisto.activity.FlowzrSyncActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FlowzrSyncActivity.me = this;

    mNotifyBuilder = new NotificationCompat.Builder(getApplicationContext());
    nm = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
    setContentView(R.layout.flowzr_sync);
    restoreUIFromPref();//from w w  w. jav  a 2s  .c  o  m

    AccountManager accountManager = AccountManager.get(getApplicationContext());
    final Account[] accounts = accountManager.getAccountsByType("com.google");
    if (accounts.length < 1) {
        new AlertDialog.Builder(this).setTitle(getString(R.string.flowzr_sync_error))
                .setMessage(R.string.account_required)
                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        finish();
                    }
                }).show();
    }
    //checkbox
    CheckBox chk = (CheckBox) findViewById(R.id.chk_sync_from_zero);
    OnClickListener chk_listener = new OnClickListener() {
        public void onClick(View v) {
            lastSyncLocalTimestamp = 0;
            renderLastTime(0);
            flowzrSyncEngine.resetLastTime(getApplicationContext());
        }
    };
    chk.setOnClickListener(chk_listener);
    //radio crendentials
    RadioGroup radioGroupCredentials = (RadioGroup) findViewById(R.id.radioCredentials);
    OnClickListener radio_listener = new OnClickListener() {
        public void onClick(View v) {
            RadioButton radioButtonSelected = (RadioButton) findViewById(v.getId());
            for (Account account : accounts) {
                if (account.name == radioButtonSelected.getText()) {
                    lastSyncLocalTimestamp = 0;
                    renderLastTime(0);
                    flowzrSyncEngine.resetLastTime(getApplicationContext());
                    useCredential = account;
                }
            }
        }
    };
    radioGroupCredentials.setOnClickListener(radio_listener);
    //initialize value
    for (int i = 0; i < accounts.length; i++) {
        RadioButton rb = new RadioButton(this);
        radioGroupCredentials.addView(rb); //, 0, lp); 
        rb.setOnClickListener(radio_listener);
        rb.setText(((Account) accounts[i]).name);
        String prefAccount = MyPreferences.getFlowzrAccount(this);
        if (prefAccount != null) {
            if (accounts[i].name.equals(prefAccount)) {
                useCredential = accounts[i];
                rb.toggle(); //.setChecked(true);
            }
        }
    }

    bOk = (Button) findViewById(R.id.bOK);
    bOk.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            startSync();

        }
    });

    Button bCancel = (Button) findViewById(R.id.bCancel);
    bCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            if (flowzrSyncEngine != null) {
                flowzrSyncEngine.isCanceled = true;
            }
            isRunning = false;
            setResult(RESULT_CANCELED);
            setReady();
            startActivity(new Intent(getApplicationContext(), MainActivity.class));
            //finish();
        }
    });

    Button textViewAbout = (Button) findViewById(R.id.buySubscription);
    textViewAbout.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (isOnline(FlowzrSyncActivity.this)) {
                visitFlowzr(useCredential);
            } else {
                showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network);
            }
        }
    });

    Button textViewAboutAnon = (Button) findViewById(R.id.visitFlowzr);
    textViewAboutAnon.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (isOnline(FlowzrSyncActivity.this)) {
                visitFlowzr(null);
            } else {
                showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network);
            }
        }
    });

    TextView textViewNotes = (TextView) findViewById(R.id.flowzrPleaseNote);
    textViewNotes.setMovementMethod(LinkMovementMethod.getInstance());
    textViewNotes.setText(Html.fromHtml(getString(R.string.flowzr_terms_of_use)));
    if (MyPreferences.isAutoSync(this)) {
        if (checkPlayServices()) {
            gcm = GoogleCloudMessaging.getInstance(this);
            regid = getRegistrationId(getApplicationContext());

            if (regid.equals("")) {
                registerInBackground();
            }
            Log.i(TAG, "Google Cloud Messaging registered as :" + regid);
        } else {
            Log.i(TAG, "No valid Google Play Services APK found.");
        }
    }
}

From source file:org.easyrpg.player.player.EasyRpgPlayerActivity.java

private void reportBug() {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setTitle(R.string.app_name);

    final SpannableString bug_msg = new SpannableString(
            getApplicationContext().getString(R.string.report_bug_msg));
    Linkify.addLinks(bug_msg, Linkify.ALL);

    // set dialog message
    alertDialogBuilder.setMessage(bug_msg).setCancelable(false)
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    ArrayList<Uri> files = new ArrayList<Uri>();
                    String savepath = getIntent().getStringExtra(TAG_SAVE_PATH);
                    files.add(Uri.fromFile(new File(savepath + "/easyrpg_log.txt")));
                    for (File f : GameBrowserHelper.getSavegames(new File(savepath))) {
                        files.add(Uri.fromFile(f));
                    }/*from   w  w w .ja  v a  2 s .co m*/

                    if (Build.VERSION.SDK_INT >= 24) {
                        // Lazy workaround as suggested on https://stackoverflow.com/q/38200282
                        try {
                            Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure");
                            m.invoke(null);
                        } catch (Exception e) {
                            Log.i("EasyRPG", "Bug report: Calling disableDeathOnFileUriExposure failed");
                        }
                    }

                    Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
                    intent.setData(Uri.parse("mailto:"));
                    intent.setType("*/*");
                    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "easyrpg@easyrpg.org" });
                    intent.putExtra(Intent.EXTRA_SUBJECT, "Bug report");
                    intent.putExtra(Intent.EXTRA_TEXT,
                            getApplicationContext().getString(R.string.report_bug_mail));
                    intent.putExtra(Intent.EXTRA_STREAM, files);
                    if (intent.resolveActivity(getPackageManager()) != null) {
                        startActivity(intent);
                    }
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });

    AlertDialog alertDialog = alertDialogBuilder.create();

    alertDialog.show();

    ((TextView) alertDialog.findViewById(android.R.id.message))
            .setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:com.pindroid.fragment.ViewBookmarkFragment.java

private void loadBookmark() {
    if (bookmark != null) {
        if (viewType == BookmarkViewType.VIEW) {

            Date d = new Date(bookmark.getTime());

            if (bookmark.getDescription() != null && !bookmark.getDescription().equals("null"))
                mTitle.setText(bookmark.getDescription());

            mUrl.setText(bookmark.getUrl());

            if (bookmark.getNotes() != null && !bookmark.getNotes().equals("null")
                    && !bookmark.getNotes().equals("")) {
                mNotes.setText(bookmark.getNotes());
                notesSection.setVisibility(View.VISIBLE);
            } else {
                notesSection.setVisibility(View.GONE);
            }//w  w w .  j  a v  a  2  s.c  om

            mTime.setText(d.toString());

            mTags.setMovementMethod(LinkMovementMethod.getInstance());
            SpannableStringBuilder tagBuilder = new SpannableStringBuilder();

            if (bookmark.getTags().size() > 0) {
                for (Tag t : bookmark.getTags()) {
                    addTag(tagBuilder, t, tagOnClickListener);
                }

                mTags.setText(tagBuilder);

                tagsSection.setVisibility(View.VISIBLE);
            } else {
                tagsSection.setVisibility(View.GONE);
            }

            if (isMyself()) {
                Uri.Builder ub = new Uri.Builder();
                ub.scheme("content");
                ub.authority(BookmarkContentProvider.AUTHORITY);
                ub.appendPath("bookmark");
                ub.appendPath(Integer.toString(bookmark.getId()));

                getActivity().getContentResolver().unregisterContentObserver(observer);
                getActivity().getContentResolver().registerContentObserver(ub.build(), true, observer);

                mUsername.setText(bookmark.getAccount());

                if (bookmark.getToRead() && bookmark.getShared()) {
                    bookmarkIcon.setImageResource(R.drawable.ic_unread);
                } else if (!bookmark.getToRead() && bookmark.getShared()) {
                    bookmarkIcon.setImageResource(R.drawable.ic_bookmark);
                } else if (bookmark.getToRead() && !bookmark.getShared()) {
                    bookmarkIcon.setImageResource(R.drawable.ic_unread_private);
                } else if (!bookmark.getToRead() && !bookmark.getShared()) {
                    bookmarkIcon.setImageResource(R.drawable.ic_bookmark_private);
                }

            } else {
                if (bookmark.getAccount() != null) {
                    SpannableStringBuilder builder = new SpannableStringBuilder();
                    int start = builder.length();
                    builder.append(bookmark.getAccount());
                    int end = builder.length();

                    AccountSpan span = new AccountSpan(bookmark.getAccount());
                    span.setOnAccountClickListener(accountOnClickListener);

                    builder.setSpan(span, start, end, 0);

                    mUsername.setText(builder);
                }

                mUsername.setMovementMethod(LinkMovementMethod.getInstance());
            }
        } else if (viewType == BookmarkViewType.READ) {
            showInWebView(Constants.INSTAPAPER_URL + bookmark.getUrl());

            if (isMyself() && bookmark.getToRead() && SettingsHelper.getMarkAsRead(getActivity()))
                bookmarkSelectedListener.onBookmarkMark(bookmark);
        } else if (viewType == BookmarkViewType.WEB) {
            showInWebView(bookmark.getUrl());
        }
    } else {
        clearView();
    }
}

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

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }/*from  w ww  .  j a  va 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:com.happysanta.vkspy.Fragments.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    context = getActivity();/*w ww . j  av a  2s  .c  o m*/

    if (savedInstanceState != null && UberFunktion.loading) {
        ProgressDialog dialog = new ProgressDialog(context);
        dialog.setMessage(context.getString(R.string.durov_function_activating_message));
        UberFunktion.putNewDialogWindow(dialog);
        dialog.show();
    }

    View rootView = inflater.inflate(R.layout.fragment_main, null);

    View happySanta = inflater.inflate(R.layout.main_santa, null);

    TextView happySantaText = (TextView) happySanta.findViewById(R.id.happySantaText);
    happySantaText.setText(Html.fromHtml(context.getString(R.string.app_description)));
    TextView happySantaLink = (TextView) happySanta.findViewById(R.id.happySantaLink);
    happySantaLink.setText(Html.fromHtml("vk.com/<b>happysanta</b>"));
    happySantaLink.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://vk.com/happysanta"));
            startActivity(browserIntent);
        }
    });
    happySanta.setOnClickListener(new View.OnClickListener() {
        int i = 1;

        @Override
        public void onClick(View v) {
            if (i < 10)
                i++;
            else {
                i = 0;
                File F = Logs.getFile();
                Uri U = Uri.fromFile(F);
                Intent i = new Intent(Intent.ACTION_SEND);
                i.setType("text/plain");
                i.putExtra(Intent.EXTRA_STREAM, U);
                startActivity(Intent.createChooser(i, "What should we do with logs?"));
            }
        }
    });

    SharedPreferences longpollPreferences = context.getSharedPreferences("longpoll",
            Context.MODE_MULTI_PROCESS);
    boolean longpollStatus = longpollPreferences.getBoolean("status", true);

    /*Bitmap tile = BitmapFactory.decodeResource(context.getResources(), R.drawable.underline);
    BitmapDrawable tiledBitmapDrawable = new BitmapDrawable(context.getResources(), tile);
    tiledBitmapDrawable.setTileModeX(Shader.TileMode.REPEAT);
    //tiledBitmapDrawable.setTileModeY(Shader.TileMode.REPEAT);
            
    santaGroundView.setBackgroundDrawable(tiledBitmapDrawable);
            
    BitmapDrawable bitmap = new BitmapDrawable(BitmapFactory.decodeResource(
        getResources(), R.drawable.underline2));
    bitmap.setTileModeX(Shader.TileMode.REPEAT);
    */
    LinearLayout layout = (LinearLayout) happySanta.findViewById(R.id.line);
    Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    int width = display.getWidth(); // deprecated

    for (int i = 0; width % (341 * i + 1) < width; i++) {
        layout.addView(new ImageView(context) {
            {
                setImageResource(R.drawable.underline2);
                setLayoutParams(new ViewGroup.LayoutParams(341, Helper.convertToDp(4)));
                setScaleType(ScaleType.CENTER_CROP);
            }
        });
    }

    ListView preferencesView = (ListView) rootView.findViewById(R.id.preference);
    preferencesView.addHeaderView(happySanta, null, false);
    ArrayList<PreferenceItem> preferences = new ArrayList<PreferenceItem>();
    /*
    preferences.add(new PreferenceItem(getUberfunction(), getUberfunctionDescription()) {
    @Override
    public void onClick() {
            
        if(UberFunktion.loading) {
            ProgressDialog dialog = new ProgressDialog(context);
            dialog.setMessage(context.getString(R.string.durov_function_activating_message));
            UberFunktion.putNewDialogWindow(dialog);
            dialog.show();
            return;
        }
            
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        final AlertDialog selector;
        View durov = getActivity().getLayoutInflater().inflate(R.layout.durov, null);
        SharedPreferences durovPreferences = context.getSharedPreferences("durov", Context.MODE_MULTI_PROCESS);
        boolean updateOnly = durovPreferences.getBoolean("loaded", false);
        if(updateOnly)
            ((TextView)durov.findViewById(R.id.description)).setText(R.string.durov_function_activated);
            
            
        if(Memory.users.getById(1)!=null && !updateOnly) {
            builder.setTitle(R.string.durov_joke_title);
            ((TextView)durov.findViewById(R.id.description)).setText(R.string.durov_joke_message);
            ( durov.findViewById(R.id.cat)).setVisibility(View.VISIBLE);
            
            builder.setNegativeButton(R.string.durov_joke_button, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
            
                    BugSenseHandler.sendEvent("? ?  ");
                }
            });
            BugSenseHandler.sendEvent("DUROV FRIEND CATCHED!!1");
        }else{
            builder.setTitle(R.string.durov_start_title);
            
            ( durov.findViewById(R.id.photo)).setVisibility(View.VISIBLE);
            ImageLoader.getInstance().displayImage("http://cs9591.vk.me/v9591001/70/VPSmUR954fQ.jpg",(ImageView) durov.findViewById(R.id.photo));
            builder.
                    setPositiveButton(updateOnly ? R.string.durov_start_update : R.string.durov_start_ok, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
            
                            BugSenseHandler.sendEvent("  ");
                            ProgressDialog uberfunctionDialog = ProgressDialog.show(getActivity(),
                                    context.getString(R.string.durov_function_activating_title),
                                    context.getString(R.string.durov_function_activating_message),
                                    true,
                                    false);
                            UberFunktion.initialize(uberfunctionDialog);
            
                        }
                    });
            builder.setNegativeButton(R.string.durov_start_cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
            
                    try {
                        Intent browserIntent = new Intent(
                                Intent.ACTION_VIEW,
                                Uri.parse("https://vk.com/id1")
                        );
                        startActivity(browserIntent);
            
                    }catch(Exception exp){
                        AlertDialog.Builder errorShower = new AlertDialog.Builder(getActivity());
                        if (exp instanceof ActivityNotFoundException) {
                            errorShower.setTitle(R.string.error);
                            errorShower.setMessage(R.string.no_browser);
            
                        } else {
                            errorShower.setTitle(R.string.error);
                            errorShower.setMessage(R.string.unknown_error);
                        }
                        errorShower.show();
                    }
                    BugSenseHandler.sendEvent("? ?  ");
                }
            });
        }
            
        builder.setView(durov);
        selector = builder.create();
        selector.show();
    }
    });
    */

    preferences.add(new ToggleablePreferenceItem(getEnableSpy(), null, longpollStatus) {

        @Override
        public void onToggle(Boolean isChecked) {
            longpollToggle(isChecked);
        }
    });

    preferences.add(new PreferenceItem(getAdvancedSettings()) {
        @Override
        public void onClick() {
            startActivity(new Intent(context, SettingsActivity.class));
        }
    });

    preferences.add(new PreferenceItem(getAbout()) {
        @Override
        public void onClick() {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            final AlertDialog aboutDialog;
            builder.setTitle(R.string.app_about).setCancelable(true)
                    .setPositiveButton(R.string.app_about_button, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    });

            View aboutView = getActivity().getLayoutInflater().inflate(R.layout.about, null);

            TextView aboutDescription = (TextView) aboutView.findViewById(R.id.description);
            aboutDescription.setText(Html.fromHtml(getResources().getString(R.string.app_about_description)));
            aboutDescription.setMovementMethod(LinkMovementMethod.getInstance());

            aboutView.findViewById(R.id.license).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    Intent browserIntent = new Intent(context, InfoActivity.class);
                    startActivity(browserIntent);
                }
            });

            builder.setView(aboutView);
            aboutDialog = builder.create();
            aboutDialog.setCanceledOnTouchOutside(true);
            aboutDialog.show();
        }
    });
    preferencesView.setAdapter(new PreferenceAdapter(context, preferences));

    return rootView;

}

From source file:com.mine.psf.PsfFileBrowserActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    // show dialog according to the id
    final String msg;
    if (id == ID_ABOUT) {
        // Get version code
        String versionString = "";
        PackageManager manager = getPackageManager();
        try {/*  w w w. j  av  a2  s.  com*/
            PackageInfo info = manager.getPackageInfo(getPackageName(), 0);
            versionString = info.versionName;
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }
        // Format dialog msg
        msg = String.format(getString(R.string.sexypsf_about), versionString);
    } else {
        Log.e(LOGTAG, "Unknown dialog id");
        msg = "";
    }

    final TextView msgView = new TextView(this);
    msgView.setText(msg);
    msgView.setAutoLinkMask(Linkify.ALL);
    msgView.setTextAppearance(this, android.R.style.TextAppearance_Medium);
    msgView.setMovementMethod(LinkMovementMethod.getInstance());

    return new AlertDialog.Builder(this).setView(msgView).setCancelable(true)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    /* User clicked OK so do some stuff */
                }
            }).create();
}