List of usage examples for android.widget TextView setMovementMethod
public final void setMovementMethod(MovementMethod movement)
From source file:com.limewoodmedia.nsdroid.fragments.RMBFragment.java
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { root = inflater.inflate(R.layout.rmb, null, false); list = (ListView) root.findViewById(R.id.rmb_messages); dimmer = (FrameLayout) root.findViewById(R.id.dimmer); messageBox = (EditText) root.findViewById(R.id.rmb_post_message); postArea = (ViewGroup) root.findViewById(R.id.rmb_post_area); postClose = (Button) postArea.findViewById(R.id.rmb_post_close); postClose.setOnClickListener(this); postSend = (Button) postArea.findViewById(R.id.rmb_post_send); postSend.setOnClickListener(this); posts = new ArrayList<RMBMessage>(); final String deletedMessage = getString(R.string.message_deleted_by_author); listAdapter = new ArrayAdapter<RMBMessage>(context, 0, posts) { @Override/*www. ja va2 s.c om*/ public View getView(int position, View convertView, ViewGroup parent) { View view; TextView nation = null, msg; RMBMessage post = getItem(position); if (convertView == null) { if (post.message.compareTo(deletedMessage) == 0) { // This is a deleted message view = inflater.inflate(R.layout.rmb_post_deleted, null); view.setTag(deletedMessage); } else { view = inflater.inflate(R.layout.rmb_post, null); nation = (TextView) view.findViewById(R.id.rmb_poster); nation.setMovementMethod(LinkMovementMethod.getInstance()); } msg = (TextView) view.findViewById(R.id.rmb_message); msg.setMovementMethod(LinkMovementMethod.getInstance()); } else { if ((post.message.compareTo(deletedMessage) == 0 && convertView.getTag() == deletedMessage) || (post.message.compareTo(deletedMessage) != 0 && convertView.getTag() != deletedMessage)) { view = convertView; msg = (TextView) view.findViewById(R.id.rmb_message); } else { if (post.message.compareTo(deletedMessage) == 0) { // This is a deleted message view = inflater.inflate(R.layout.rmb_post_deleted, null); view.setTag(deletedMessage); } else { view = inflater.inflate(R.layout.rmb_post, null); nation = (TextView) view.findViewById(R.id.rmb_poster); nation.setMovementMethod(LinkMovementMethod.getInstance()); } msg = (TextView) view.findViewById(R.id.rmb_message); msg.setMovementMethod(LinkMovementMethod.getInstance()); } nation = (TextView) view.findViewById(R.id.rmb_poster); } if (view.getTag() == deletedMessage) { msg.setText(Html.fromHtml("Post self-deleted by <a href='com.limewoodMedia.nsdroid.nation://" + post.nation + "'>" + TagParser.idToName(post.nation) + "</a>.")); } else { long timestamp = post.timestamp; String time = TagParser.parseTimestamp(getContext(), timestamp); String poster = "<a href=\"com.limewoodMedia.nsdroid.nation://" + post.nation + "\">" + TagParser.idToName(post.nation) + "</a><br />" + time; if (post.embassy != null) { poster += " from<br /><a href=\"com.limewoodMedia.nsdroid.region://" + TagParser.nameToId(post.embassy) + "\">" + post.embassy + "</a>"; } nation.setText(Html.fromHtml(poster)); msg.setText(TagParser.parseTagsFromHtml(post.message, true)); } return view; } }; list.setAdapter(listAdapter); registerForContextMenu(list); return root; }
From source file:com.keylesspalace.tusky.AccountActivity.java
private void onObtainAccountSuccess(Account account) { loadedAccount = account;//from w w w . j a va2 s. c o m TextView username = (TextView) findViewById(R.id.account_username); TextView displayName = (TextView) findViewById(R.id.account_display_name); TextView note = (TextView) findViewById(R.id.account_note); CircularImageView avatar = (CircularImageView) findViewById(R.id.account_avatar); ImageView header = (ImageView) findViewById(R.id.account_header); String usernameFormatted = String.format(getString(R.string.status_username_format), account.username); username.setText(usernameFormatted); displayName.setText(account.getDisplayName()); note.setText(account.note); note.setLinksClickable(true); note.setMovementMethod(LinkMovementMethod.getInstance()); if (account.locked) { accountLockedView.setVisibility(View.VISIBLE); } else { accountLockedView.setVisibility(View.GONE); } Picasso.with(this).load(account.avatar).placeholder(R.drawable.avatar_default) .error(R.drawable.avatar_error).into(avatar); Picasso.with(this).load(account.header).placeholder(R.drawable.account_header_missing).into(header); NumberFormat nf = NumberFormat.getInstance(); // Add counts to the tabs in the TabLayout. String[] counts = { nf.format(Integer.parseInt(account.statusesCount)), nf.format(Integer.parseInt(account.followingCount)), nf.format(Integer.parseInt(account.followersCount)), }; for (int i = 0; i < tabLayout.getTabCount(); i++) { TabLayout.Tab tab = tabLayout.getTabAt(i); if (tab != null) { View view = tab.getCustomView(); if (view != null) { TextView total = (TextView) view.findViewById(R.id.total); total.setText(counts[i]); } } } }
From source file:se.toxbee.sleepfighter.activity.EditGPSFilterAreaActivity.java
/** * Sets up the help splash.//from w w w .j a v a 2 s. co m */ private void setupSplash() { this.splashInfoContainer = (LinearLayout) this.findViewById(R.id.edit_gpsfilter_area_splash); TextView textView = (TextView) this.splashInfoContainer.findViewById(R.id.edit_gpsfilter_area_splash_text); textView.setText(Html.fromHtml(this.getString(R.string.edit_gpsfilter_area_splash_text))); textView.setMovementMethod(new ScrollingMovementMethod()); // Define fade out animation. this.splashFadeOut = new AlphaAnimation(1.00f, 0.00f); this.splashFadeOut.setDuration(SPLASH_FADE_DELAY); this.splashFadeOut.setAnimationListener(new AnimationListener() { public void onAnimationStart(Animation animation) { } public void onAnimationRepeat(Animation animation) { } public void onAnimationEnd(Animation animation) { splashInfoContainer.setVisibility(View.GONE); } }); // Don't show if not new and we got polygon. if (!this.isConsideredFresh()) { this.splashInfoContainer.setVisibility(View.GONE); } }
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 {//from w w w . j a v a 2s . co m helpText.setVisibility(View.GONE); return helpText; } }
From source file:com.andfchat.frontend.activities.ChatScreen.java
public void showDescription() { LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.popup_description, null); int height = (int) (this.height * 0.8f); int width = (int) (this.width * 0.8f); final PopupWindow descriptionPopup = new FListPopupWindow(layout, width, height); descriptionPopup.showAtLocation(chatFragment.getView(), Gravity.CENTER, 0, 0); final TextView descriptionText = (TextView) layout.findViewById(R.id.descriptionText); descriptionText.setText(SmileyReader.addSmileys(this, chatroomManager.getActiveChat().getDescription())); // Enable touching/clicking links in text descriptionText.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.todoroo.astrid.adapter.UpdateAdapter.java
private void setupUserActivityRow(View view, UserActivity activity, User user) { final AsyncImageView pictureView = (AsyncImageView) view.findViewById(R.id.picture); {/*from w w w .j av a2 s . co m*/ if (user.containsNonNullValue(USER_PICTURE)) { String pictureUrl = user.getPictureUrl(USER_PICTURE, RemoteModel.PICTURE_THUMB); pictureView.setUrl(pictureUrl); } else { pictureView.setUrl(null); } pictureView.setVisibility(View.VISIBLE); } final AsyncImageView commentPictureView = (AsyncImageView) view.findViewById(R.id.comment_picture); { String pictureThumb = activity.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_MEDIUM); String pictureFull = activity.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_LARGE); Bitmap updateBitmap = null; if (TextUtils.isEmpty(pictureThumb)) updateBitmap = activity.getPictureBitmap(UserActivity.PICTURE); setupImagePopupForCommentView(view, commentPictureView, pictureThumb, pictureFull, updateBitmap, activity.getValue(UserActivity.MESSAGE), fragment, imageCache); } // name final TextView nameView = (TextView) view.findViewById(R.id.title); { nameView.setText( getUpdateComment((AstridActivity) fragment.getActivity(), activity, user, linkColor, fromView)); nameView.setMovementMethod(new LinkMovementMethod()); nameView.setTextColor(color); } // date final TextView date = (TextView) view.findViewById(R.id.date); { CharSequence dateString = DateUtils.getRelativeTimeSpanString( activity.getValue(UserActivity.CREATED_AT), DateUtilities.now(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE); date.setText(dateString); } }
From source file:ngoc.com.pedometer.ui.Fragment_Overview.java
private void showAboutDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.about);/*from www . java2 s.com*/ TextView tv = new TextView(getActivity()); tv.setPadding(10, 10, 10, 10); tv.setText(R.string.about_text_links); try { tv.append(getString(R.string.about_app_version, getActivity().getPackageManager() .getPackageInfo(getActivity().getPackageName(), 0).versionName)); } catch (PackageManager.NameNotFoundException e1) { // should not happen as the app is definitely installed when // seeing the dialog e1.printStackTrace(); } tv.setMovementMethod(LinkMovementMethod.getInstance()); builder.setView(tv); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); }
From source file:org.appcelerator.titanium.util.TiUIHelper.java
public static void linkifyIfEnabled(final TextView tv, final Object autoLink) { if (autoLink != null) { //Default to Ti.UI.AUTOLINK_NONE boolean success = Linkify.addLinks(tv, TiConvert.toInt(autoLink, 0) & Linkify.ALL); if (success && tv.getText() instanceof Spanned) { tv.setMovementMethod(LinkMovementMethod.getInstance()); }//from ww w . j av a 2s. c o m } }
From source file:org.wheelmap.android.fragment.InfoFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_credit_screen, container, false); TextView openStreetMapLink = (TextView) v.findViewById(R.id.openStreetMapLink); TextView openMapBoxLink = (TextView) v.findViewById(R.id.openMapBox); TextView openNicolasLink = (TextView) v.findViewById(R.id.linkNicolasMollet); String linkOpenStreetMap = "https://www.openstreetmap.org/copyright"; String linkOpenMapBox = "http://mapbox.com/about/maps/"; String linkOpenNicolas = "https://mapicons.mapsmarker.com"; openStreetMapLink.setClickable(true); openMapBoxLink.setClickable(true);//from ww w .j a v a 2 s.co m String text = "<a href=" + linkOpenStreetMap + ">" + openStreetMapLink.getText() + "</a>"; openStreetMapLink.setText(Html.fromHtml(text)); String text1 = "<a href=" + linkOpenMapBox + ">" + openMapBoxLink.getText() + "</a>"; openMapBoxLink.setText(Html.fromHtml(text1)); String text2 = "<a href=" + linkOpenNicolas + ">" + openNicolasLink.getText() + "</a>"; openNicolasLink.setText(Html.fromHtml(text2)); openStreetMapLink.setMovementMethod(LinkMovementMethod.getInstance()); openMapBoxLink.setMovementMethod(LinkMovementMethod.getInstance()); openNicolasLink.setMovementMethod(LinkMovementMethod.getInstance()); return v; }
From source file:de.frank_durr.ble_v_monitor.MainActivity.java
private void showAboutDialog() { View view = getLayoutInflater().inflate(R.layout.dialog_about, null, false); TextView textView = (TextView) view.findViewById(R.id.about_message); textView.setText(Html.fromHtml(getString(R.string.about_message))); textView.setMovementMethod(LinkMovementMethod.getInstance()); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(R.mipmap.ic_launcher); builder.setTitle(R.string.app_name); builder.setView(view);//from w ww. ja v a 2s .co m builder.create(); builder.show(); }