spannable

Spannable String Error

白昼怎懂夜的黑 提交于 2019-12-31 02:59:11
问题 I am trying to display some text in an alert dialog box as a hyperlink. Part of the process requires me to use SpannableString to format some text. The problem is that my application experiences a runtime error on the SpannableString part of my code. TextView Tv= (TextView) findViewById(R.id.textView3); SpannableString s = new SpannableString("www.google.com"); Linkify.addLinks(s, Linkify.WEB_URLS); Tv.setText(s); Tv.setMovementMethod(LinkMovementMethod.getInstance()); I looked in the DDMS

How to make text underline and remove text at the same time

孤人 提交于 2019-12-24 18:10:38
问题 I have a text in which there is indicator tag that indicate from where i will make text underline, I want to make text underline from that indicator also want to remove indicator so that it wont appear in string, here is what I'm trying: String consent = "By clicking this, you confirm you understand the services provided by your Health at Hand doctor and give <clickable>consent</clickable> to proceed."; int i1 = consent.indexOf(">"); int i2 = consent.indexOf("</"); consentCheck

Add an image to iText pdf in Android

爱⌒轻易说出口 提交于 2019-12-23 18:28:01
问题 I have an String containing images like "My string [img src=image_from_drawable/] blablabla". I'm able to parse this string as Spannable to show that drawable on my TextView, with the following code: static public Spannable formatAbility(String _ability) { Spannable spannable = spannableFactory.newSpannable(_ability); addImages(mContext, spannable); return spannable; } private static boolean addImages(Context context, Spannable spannable) { Pattern refImg = Pattern .compile("\\Q[img src=\\E(

setSpan() on EditText deletes other spans

帅比萌擦擦* 提交于 2019-12-22 14:47:26
问题 I have a bold button that, when pressed, is supposed to change the typeface of the selected text in the EditText field . This all works perfectly, with one exception. If there is bold typeface elsewhere in the EditText , and I try to create a new bold section, the original section is changed back to normal . For example, this string: Bold not bold more bold. If I highlight any of the normal words and press the button, they do become bold , but the first word becomes normal . I can't see any

How come my spannable isn't shown?

旧街凉风 提交于 2019-12-22 04:08:23
问题 Background I'm trying to use a simple SpannableString on a TextView , based on an UnderDotSpan class I've found (here). The original UnderDotSpan just puts a dot of a specific size and color below the text itself (not overlapping). What I'm trying is to first use it normally, and then use a customized drawable instead of a dot. The problem As opposed to a normal span usage, this one just doesn't show anything. Not even the text. Here's how it's done for a normal span: val text = "1" val

How to set font style of selected text using custom typeface through spannable method

若如初见. 提交于 2019-12-21 22:34:06
问题 I want to set style to selected text from EditText using custom typeface . I am getting below error at compile time. The constructor StyleSpan(Typeface) is undefined . Below code I am applying. int start=editbox.getSelectionStart(); int end=editbox.getSelectionEnd(); Spannable span=(Spannable)editbox.getText(); StyleSpan f = new StyleSpan( Typeface.createFromAsset(getAssets(), "fonts/genbkbasr.ttf")); span.setSpan(f, start,end, 0); Thanks. 回答1: I wrote a class to work around this limitation.

Handle clicks on TextView's links while using Linkify for finding and setting the links inside the text

冷暖自知 提交于 2019-12-21 12:26:03
问题 i have a TextView filled with text which i get from a server. I'm using Linkify for handling all the link searching and for setting a URLSpan where needed throughout its addLinks method. The problem is that the default behavior when clicking a link is opening it in a browser, what i want is to get the clicked link and handle it my self. I don't see any method of Linkify which let me set a "OnClick" or something... Thank for your help :) 回答1: Ok so i finally managed to set my own

How to create a empty bullet paragraph by BulletSpan?

為{幸葍}努か 提交于 2019-12-20 02:22:06
问题 I wanted to create a empty bullet paragraph, but it didn't work. This is my code: EditText contentET = (EditText) findViewById(R.id.content); contentET.setText("abc\n123\n"); Spannable s = contentET.getText(); s.setSpan(new BulletSpan(), 0, 1, Spannable.SPAN_INCLUSIVE_INCLUSIVE); s.setSpan(new BulletSpan(), 4, 5, Spannable.SPAN_INCLUSIVE_INCLUSIVE); s.setSpan(new BulletSpan(), 7, 8, Spannable.SPAN_INCLUSIVE_INCLUSIVE); contentET.setText(s); When i ran above code, it seemed this line doesn't

How do I achieve a Facebook Messenger/ Google Hangouts like layout to preview selected items in search bar on ANDROID?

给你一囗甜甜゛ 提交于 2019-12-19 03:53:12
问题 Basically what I want to create can be best illustrated from a screenshot. I have a listview of people just like FB Messenger app. I want the ability for my users to have a search bar like the one shown in the screenshots. It should have the following properties: 1) Search bar should preview names of people selected in the list view 2) People can be de-selected by hitting backspace on any name in the preview search bar 3) The search bar should be able to filter the bottom list of people as

How to use support library fonts feature as a part of the TextView content (using spannable)?

余生颓废 提交于 2019-12-18 05:52:29
问题 Background The support library (docs here) allows you to use TTF fonts files in the "res/font" folder, either in XML : app:fontFamily="@font/lato_black" or via code: val typeface = ResourcesCompat.getFont(context, R.font.lato_black) The problem While I know it's possible to use spannable technique to set different styles in parts of the TextView content (such as bold, italic, colors,etc...) , the only thing I've found for setting a different font, is by using the built in fonts of the OS, as