spannablestring

How to get String from Intent?

南笙酒味 提交于 2019-12-11 23:50:46
问题 I wrote some code to get text from the EditView, put it in the Intent Extras and set it in a TextView on other Activity. Here is my code from the sending Activity Intent intent = new Intent(MyLayoutActivity.this, LayoutForOneActivity.class); intent.putExtra("CaptionOne", String.valueOf(txt_caption1.getText())); startActivity(intent); And here is the code from my receiving Activity Intent intent1 = getIntent(); Bundle bundle = intent1.getExtras(); if (bundle != null) { caption = bundle

SpannableStringBuilder setSpan doesn't work on Arabic text

人盡茶涼 提交于 2019-12-11 19:24:46
问题 I am trying to build an Arabic string that contains spacial caracters with different color, text should be black and special catacters red, and different size between sentences. Like this: This is my TexView definition: <com.neopixl.pixlui.components.textview.TextView android:id="@+id/sura" android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="@dimen/kuran_sure_text_size" android:textDirection="rtl" pixlui:typeface="fatih_araz_font.ttf"/> And this is my

Delete entire ImageSpan when the part of it is deleted

非 Y 不嫁゛ 提交于 2019-12-11 17:16:43
问题 I'm trying to implement Emoji's in my app and I should use short codes (like :dog: , :cat: ), not unicode. I have two devices to test on and two different behaviours of EditText and ImageSpan in it. First: Meizu PRO 6, Android 6.0 (API 23) Everything works as I want. When you tap backspace on the spanned text, it disappears from EditText completely, because full spanned part of the string was removed. For example, you have a "Hello :dog: " in your EditText ( :dog: is replaced with a picture

programmatically create styles in Android without referring to resources

对着背影说爱祢 提交于 2019-12-11 11:12:04
问题 I'm working on an app that reads in text from an XML document and then displays that text on the screen. I want to be able to create a TextAppearanceSpan object programmatically based on parameters given in the XML document (font, size, color, bold/italic, etc.) that don't rely on Resource files (for SpannableString s in my TextView). I was looking at the following constructor: TextAppearanceSpan(String family, int style, int size, ColorStateList color, ColorStateList linkColor) but I can't

Extra line breaks at end of text

爷,独闯天下 提交于 2019-12-11 10:56:36
问题 I seem to be getting what seems like some extra line breaks after using this method to set the text of a TextView message.setText(Html.fromHtml( message )); How can I remove these? They cause my layout to get warped since it adds two extra lines to the output. The string was saved to my sqlite database via Html.toHtml( editText.getText() ).trim(); Initial string input : hello Log output of the message variable: <p dir="ltr">hello</p> 回答1: Looks like toHtml assumes everything should be in a <p

ReplacementSpan in multiautocomplete textview overlap

我与影子孤独终老i 提交于 2019-12-11 09:27:33
问题 Hi i have multiple autocomplete text view with space tokenizer and use ReplacementSpan for background color change in each contacts my custom replacement code is public class MyForgroudSpan : ReplacementSpan { public override void Draw(Canvas canvas, ICharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) { var rect = new RectF(x , top, x + paint.MeasureText(text, start, end)+8, bottom); paint.Color = Android.Graphics.Color.ParseColor("#E5E5E6"); canvas

Android CARDSLIB: How to propagate card click to Spannable String?

房东的猫 提交于 2019-12-11 07:11:17
问题 I'm trying to solve a problem I'm having with Cardslib and spannable text. Cards display correctly and each card shows the text I made spannable. Each spanned text has an overriden onClick listener that replaces current fragment. The problem seems to be that Cardslib is catching the onClick event and it isn't propagated to the handlers inside the spannable text. Does that make sense? Thanks in advance! 来源: https://stackoverflow.com/questions/27007531/android-cardslib-how-to-propagate-card

indexoutofboundexception : setSpan (2…2) ends beyond length 1

末鹿安然 提交于 2019-12-10 15:34:47
问题 I've a MultiAutoCompleteTextView custom control in which I am creating chips text, when user presses the space key. I do not want the user to input space initially when the textbox is empty so I put an inputFilter in order to prevent user from putting space initially. Here's the Filter Code: private void RestrictUselessSpaces(){ InputFilter filter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { for (int i = start;

Set a String Array into Bold in Android

纵然是瞬间 提交于 2019-12-10 14:16:12
问题 I have a ListView where I managed to display many texts on it. Some of the texts are formatted as BOLD . In order to make those texts bold, I used Spannable and it works! However, when I scrolled it down and up again, the index[0] goes multiple. To avoid that scene, I used a holder to hold my TextViews. I managed to solve that problem in scrolling but for some reasons, the textstyle which is BOLD, gone in my ListView. How can I do that? MainActivity.java private void populateListView() {

How to make spannable text clickable with Accessibility mode on

时间秒杀一切 提交于 2019-12-10 13:57:24
问题 I have a problem statement where i need to run my application with Accessibility setting on, to have talk back feedback, but the problem here is when i click on a TextView which have Spannable link in it, then it reads the full text but dose not allow me to click on that Spannable text separately while disabling the accessibility allows to make string multi spannable or link clickable. here is my code to make String clickable : SpannableString ss = new SpannableString("Android is a Software