List of usage examples for android.widget TextView setMovementMethod
public final void setMovementMethod(MovementMethod movement)
From source file:org.navitproject.navit.Navit.java
@Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case MY_PERMISSIONS_REQUEST_ALL: { if (grantResults.length > 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED && grantResults[1] == PackageManager.PERMISSION_GRANTED) { // ok, we got permissions } else {//from ww w .ja v a2 s . c o m AlertDialog.Builder infobox = new AlertDialog.Builder(this); infobox.setTitle(getString(R.string.permissions_info_box_title)); // TRANS infobox.setCancelable(false); final TextView message = new TextView(this); message.setFadingEdgeLength(20); message.setVerticalFadingEdgeEnabled(true); RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); message.setLayoutParams(rlp); final SpannableString s = new SpannableString(getString(R.string.permissions_not_granted)); // TRANS message.setText(s); message.setMovementMethod(LinkMovementMethod.getInstance()); infobox.setView(message); // TRANS infobox.setPositiveButton(getString(R.string.initial_info_box_OK), new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { exit(); } }); infobox.show(); } return; } } }
From source file:com.hippo.nimingban.ui.ListActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent;//from www . j a v a 2 s . c o m switch (item.getItemId()) { case android.R.id.home: if (mSlidingDrawerLayout.isDrawerOpen(Gravity.LEFT)) { mSlidingDrawerLayout.closeDrawer(Gravity.LEFT); } else { mSlidingDrawerLayout.openDrawer(Gravity.LEFT); } mSlidingDrawerLayout.closeDrawer(Gravity.RIGHT); return true; case R.id.action_rule: if (mCurrentForum != null && mCurrentForum.getNMBMsg() != null) { View view = getLayoutInflater().inflate(R.layout.dialog_rule, null); TextView tv = (TextView) view.findViewById(R.id.text); tv.setText(fixURLSpan(Html.fromHtml(mCurrentForum.getNMBMsg(), new URLImageGetter(tv, NMBApplication.getConaco(this)), null))); tv.setMovementMethod(new LinkMovementMethod2(ListActivity.this)); new AlertDialog.Builder(this).setTitle(R.string.rule).setView(view).show(); } return true; case R.id.action_create_post: if (mCurrentForum != null) { intent = new Intent(this, TypeSendActivity.class); intent.setAction(TypeSendActivity.ACTION_CREATE_POST); intent.putExtra(TypeSendActivity.KEY_SITE, mCurrentForum.getNMBSite().getId()); intent.putExtra(TypeSendActivity.KEY_ID, mCurrentForum.getNMBId()); startActivity(intent); } return true; case R.id.action_refresh: mPostHelper.refresh(); return true; case R.id.action_sort_forums: intent = new Intent(this, SortForumsActivity.class); intent.putExtra(SortForumsActivity.KEY_SITE, ACSite.getInstance().getId()); // TODO support other site startActivityForResult(intent, REQUEST_CODE_SORT_FORUMS); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.gelakinetic.selfr.CameraActivity.java
/** * Build a dialog, currently only the about dialog * * @param id An ID corresponding to the dialog to be shown * @return A Dialog to be displayed by the system */// www .jav a 2 s. c om @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ABOUT: { /* Make a new builder */ AlertDialog.Builder builder = new AlertDialog.Builder(CameraActivity.this); /* Inflate the dialog view */ View dialogView = View.inflate(CameraActivity.this, R.layout.about_dialog, null); /* Set the title */ String title; try { title = getString(R.string.app_name) + " " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { title = getString(R.string.app_name); } builder.setTitle(title); /* Set the text, with links enabled */ TextView dialogText = (TextView) dialogView.findViewById(R.id.about_dialog_text); String aboutText = getString(R.string.about_message); /* Add the build date if possible */ String buildDate = getBuildDate(); if (buildDate != null) { aboutText += buildDate + "<br>"; } dialogText.setText(formatHtmlString(aboutText)); dialogText.setMovementMethod(LinkMovementMethod.getInstance()); builder.setView(dialogView); /* Show the dialog */ return builder.create(); } default: { return super.onCreateDialog(id); } } }
From source file:org.tigase.mobile.TigaseMobileMessengerActivity.java
@Override protected Dialog onCreateDialog(int id, Bundle bundle) { switch (id) { case NEWS_DIALOG: { String str = bundle.getString("news_html"); Builder bldr = new AlertDialog.Builder(this); bldr.setTitle("News"); bldr.setCancelable(true);/* w ww . jav a2 s. co m*/ bldr.setMessage(Html.fromHtml(str)); return bldr.create(); } case CONTACT_REMOVE_DIALOG: return null; case ABOUT_DIALOG: { final Dialog dialog = new Dialog(this); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); dialog.setContentView(R.layout.about_dialog); dialog.setTitle(getString(R.string.aboutButton)); TextView tos = (TextView) dialog.findViewById(R.id.aboutTermsOfService); tos.setText(Html.fromHtml("<a href='" + getResources().getString(R.string.termsOfServiceURL) + "'>" + getResources().getString(R.string.termsOfService) + "</a>")); tos.setMovementMethod(LinkMovementMethod.getInstance()); TextView pp = (TextView) dialog.findViewById(R.id.aboutPrivacyPolicy); pp.setText(Html.fromHtml("<a href='" + getResources().getString(R.string.privacyPolicyURL) + "'>" + getResources().getString(R.string.privacyPolicy) + "</a>")); pp.setMovementMethod(LinkMovementMethod.getInstance()); Button okButton = (Button) dialog.findViewById(R.id.okButton); okButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.cancel(); } }); return dialog; } default: return null; } }
From source file:com.concentricsky.android.khanacademy.app.VideoDetailActivity.java
private void populateHeader() { View headerView = findViewById(R.id.video_header); Log.d(LOG_TAG, "populateHeader: header is " + (headerView == null ? "null" : "not null")); if (video != null && headerView != null) { ((TextView) headerView.findViewById(R.id.video_title)).setText(video.getTitle()); String desc = video.getDescription(); TextView descView = (TextView) headerView.findViewById(R.id.video_description); if (desc != null && desc.length() > 0) { descView.setText(desc);// w w w . j a va 2 s .com descView.setVisibility(View.VISIBLE); descView.setMovementMethod(new ScrollingMovementMethod()); } else { descView.setVisibility(View.GONE); } } }
From source file:com.derdoktor667.dev.thematrix.utils.AboutDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { /**//from ww w .ja v a 2 s .c o m * Get Application Version */ PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); TextView nameAndVersionView = null; TextView aboutBodyView = null; String versionName = null; PackageInfo info = null; try { if (pm != null) { info = pm.getPackageInfo(packageName, 0); } if (info != null) { versionName = info.versionName; } } catch (PackageManager.NameNotFoundException e) { versionName = Constants.VERSION_UNAVAILABLE; } /** * Build the aboutTextView aboutBodyView = null; body view and append * the link to see OSS licenses */ LayoutInflater layoutInflater = getActivity().getLayoutInflater(); View rootView = layoutInflater.inflate(R.layout.about_popup_layout, null); if (rootView != null) { nameAndVersionView = (TextView) rootView.findViewById(R.id.app_name_and_version); } if (rootView != null) { aboutBodyView = (TextView) rootView.findViewById(R.id.about_body); } if (nameAndVersionView != null) { nameAndVersionView.setText(Html.fromHtml(getString(R.string.app_name_and_version, versionName))); } if (aboutBodyView != null) { aboutBodyView.setText(Html.fromHtml(getString(R.string.about_body))); } if (aboutBodyView != null) { aboutBodyView.setMovementMethod(new LinkMovementMethod()); } return new AlertDialog.Builder(getActivity()).setView(rootView) .setPositiveButton(R.string.close, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:com.inmobi.ultrapush.AnalyzeActivity.java
private void showInstructions() { TextView tv = new TextView(this); tv.setMovementMethod(new ScrollingMovementMethod()); tv.setText(Html.fromHtml(getString(R.string.instructions_text))); new AlertDialog.Builder(this).setTitle(R.string.instructions_title).setView(tv) .setNegativeButton(R.string.dismiss, null).create().show(); }
From source file:pro.dbro.bart.TheActivity.java
public void showInfoDialog() { TextView aboutTv = (TextView) View.inflate(c, R.layout.tabletext, null); aboutTv.setText(Html.fromHtml(res.getStringArray(R.array.aboutDialog)[1])); aboutTv.setPadding(10, 0, 10, 0);//from w w w. j a v a2 s.c om aboutTv.setTextSize(18); aboutTv.setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(c).setTitle(res.getStringArray(R.array.aboutDialog)[0]) .setIcon(R.drawable.ic_launcher).setView(aboutTv).setPositiveButton("Okay!", null).show(); }
From source file:org.navitproject.navit.Navit.java
private void showInfos() { SharedPreferences settings = getSharedPreferences(NAVIT_PREFS, MODE_PRIVATE); boolean firstStart = settings.getBoolean("firstStart", true); if (firstStart) { AlertDialog.Builder infobox = new AlertDialog.Builder(this); infobox.setTitle(getString(R.string.initial_info_box_title)); // TRANS infobox.setCancelable(false);//from www . jav a 2 s. com final TextView message = new TextView(this); message.setFadingEdgeLength(20); message.setVerticalFadingEdgeEnabled(true); // message.setVerticalScrollBarEnabled(true); RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); message.setLayoutParams(rlp); final SpannableString s = new SpannableString(getString(R.string.initial_info_box_message)); // TRANS Linkify.addLinks(s, Linkify.WEB_URLS); message.setText(s); message.setMovementMethod(LinkMovementMethod.getInstance()); infobox.setView(message); // TRANS infobox.setPositiveButton(getString(R.string.initial_info_box_OK), new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { Log.e("Navit", "Ok, user saw the infobox"); } }); // TRANS infobox.setNeutralButton(getString(R.string.initial_info_box_more_info), new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { Log.e("Navit", "user wants more info, show the website"); String url = "http://wiki.navit-project.org/index.php/Navit_on_Android"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); infobox.show(); SharedPreferences.Editor edit_settings = settings.edit(); edit_settings.putBoolean("firstStart", false); edit_settings.commit(); } }
From source file:net.idlesoft.android.apps.github.activities.Repository.java
public void loadRepoInfo() { try {/* w w w.ja va 2s. co m*/ // TextView title = // (TextView)findViewById(R.id.tv_top_bar_title); // title.setText(m_jsonData.getString("name")); final TextView repo_name = (TextView) findViewById(R.id.tv_repository_info_name); repo_name.setText(mJson.getString("name")); repo_name.requestFocus(); final TextView repo_desc = (TextView) findViewById(R.id.tv_repository_info_description); repo_desc.setText(mJson.getString("description")); final TextView repo_owner = (TextView) findViewById(R.id.tv_repository_info_owner); repo_owner.setText(mJson.getString("owner")); final TextView repo_watcher_count = (TextView) findViewById(R.id.tv_repository_info_watchers); if (mJson.getInt("watchers") == 1) { repo_watcher_count.setText(mJson.getInt("watchers") + " watcher"); } else { repo_watcher_count.setText(mJson.getInt("watchers") + " watchers"); } final TextView repo_fork_count = (TextView) findViewById(R.id.tv_repository_info_forks); if (mJson.getInt("forks") == 1) { repo_fork_count.setText(mJson.getInt("forks") + " fork"); } else { repo_fork_count.setText(mJson.getInt("forks") + " forks"); } final TextView repo_website = (TextView) findViewById(R.id.tv_repository_info_website); if (mJson.getString("homepage") != "") { repo_website.setText(mJson.getString("homepage")); } else { repo_website.setText("N/A"); } /* Make the repository owner text link to his/her profile */ repo_owner.setMovementMethod(LinkMovementMethod.getInstance()); final Spannable spans = (Spannable) repo_owner.getText(); final ClickableSpan clickSpan = new ClickableSpan() { @Override public void onClick(final View widget) { final Intent i = new Intent(Repository.this, Profile.class); try { i.putExtra("username", mJson.getString("owner")); } catch (final JSONException e) { e.printStackTrace(); } startActivity(i); } }; spans.setSpan(clickSpan, 0, spans.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } catch (final JSONException e) { e.printStackTrace(); } ((Button) findViewById(R.id.btn_repository_info_branches)).setOnClickListener(new OnClickListener() { public void onClick(final View v) { final Intent intent = new Intent(Repository.this, BranchesList.class); intent.putExtra("repo_name", mRepositoryName); intent.putExtra("repo_owner", mRepositoryOwner); startActivity(intent); } }); ((Button) findViewById(R.id.btn_repository_info_issues)).setOnClickListener(new OnClickListener() { public void onClick(final View v) { final Intent intent = new Intent(Repository.this, Issues.class); intent.putExtra("repo_name", mRepositoryName); intent.putExtra("repo_owner", mRepositoryOwner); startActivity(intent); } }); ((Button) findViewById(R.id.btn_repository_info_network)).setOnClickListener(new OnClickListener() { public void onClick(final View v) { final Intent intent = new Intent(Repository.this, NetworkList.class); intent.putExtra("repo_name", mRepositoryName); intent.putExtra("username", mRepositoryOwner); startActivity(intent); } }); }