spanned

Edit Spanned Text

最后都变了- 提交于 2019-12-04 18:23:47
I need to design an editor for my project that allow user to style some part of the text. I have used an EditText and bold selected text by adding following codes in onClickListener of a button. String selectedText = "<b>" + mEditTextContent.getText().toString().substring( mEditTextContent.getSelectionStart(), mEditTextContent.getSelectionEnd() ) + "</b>"; mEditTextContent.getText().replace( mEditTextContent.getSelectionStart(), mEditTextContent.getSelectionEnd(), Html.fromHtml(selectedText) ); But i am wonder how i can toggle bold style? For example if selected text is already bolded, unbold

Android EditText: How to create an empty bullet paragraph by BulletSpan?

吃可爱长大的小学妹 提交于 2019-12-04 04:04:14
I use the same title with this question , because I think my question is very similar to that one, I read and tested the accepted answer very carefully, however the accepted answer doesn't work for me. Let me describe my question: My code looks like: EditText myEdit = (EditText) this.findViewById(R.id.myedit); myEdit.setText("a\nb\n"); Spannable s = myEdit.getText(); s.setSpan(new BulletSpan(30), 0, 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); s.setSpan(new BulletSpan(30), 2, 3, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); s.setSpan(new BulletSpan(30), 4, 4, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); myEdit

What is the difference between SPAN_POINT_MARK and SPAN_MARK_POINT?

若如初见. 提交于 2019-12-03 11:56:23
问题 I have been reading up on the docs for the Spanned/Spannable class for a project that I am working on. I have been puzzled by the definition and usage of the spans that contain MARK and POINT . A MARK seems to be defined in the Doc as "attached" to a character's location while a POINT is defined as being "glued" to a character. Thus a MARK won't move when text is changed and a POINT will move with the character it was "glued" to when text is changed. These definitions seem to show that MARK

EditText scale with selection

て烟熏妆下的殇ゞ 提交于 2019-12-03 08:14:33
问题 I have an EditText I want to zoom it, and scroll with setScaleX / setScaleY and it works fine - text is being edited in the right position. But when I try to select text - it draws selection handles to positions like when text is not scaled. It is known bug. It's expected result because handles are drawn on popup window related to view size. All actions on android.widget.Editor are targeted to its field private TextView mTextView; . And if we will set own editor by reflection, I don't know

EditText scale with selection

◇◆丶佛笑我妖孽 提交于 2019-12-02 21:53:48
I have an EditText I want to zoom it, and scroll with setScaleX / setScaleY and it works fine - text is being edited in the right position. But when I try to select text - it draws selection handles to positions like when text is not scaled. It is known bug . It's expected result because handles are drawn on popup window related to view size. All actions on android.widget.Editor are targeted to its field private TextView mTextView; . And if we will set own editor by reflection, I don't know what to do with private methods, that are no overridable. Also selection handles are drawn on Popup

Remove style on spans

僤鯓⒐⒋嵵緔 提交于 2019-12-02 15:21:58
问题 I have used this StyleSpanRemover to remove style from selected text, but i have a problem. I want to have a bold button that toggle bold style of selected text. it means if the selected text (or part of that) is not bold, bold all of them; and if all of selected text is bold, remove bold style from it. But when i use this code, after one removing bold style on a text and again bolding it, getStyle() always returns Typeface.NORMAL Here is the code i have used: boolean isAllSpansBold = true; /

Remove style on spans

天大地大妈咪最大 提交于 2019-12-02 03:58:52
I have used this StyleSpanRemover to remove style from selected text, but i have a problem. I want to have a bold button that toggle bold style of selected text. it means if the selected text (or part of that) is not bold, bold all of them; and if all of selected text is bold, remove bold style from it. But when i use this code, after one removing bold style on a text and again bolding it, getStyle() always returns Typeface.NORMAL Here is the code i have used: boolean isAllSpansBold = true; /** * Bold selected text */ Spannable spannable = new SpannableString(mEditTextContent.getText());

Spanned text in Number picker

给你一囗甜甜゛ 提交于 2019-11-30 09:40:30
问题 I have a problem with to show meter m 2 in android. I can use SpannedBuilderString for setText in TextView and it work. The problem is I want to show m 2 in Number Picker like 50 m 2 100 m 2 but Number Picker only show String and I can't. Please help me fix that. Tks everyone. 回答1: Using Unicode Character makes it very easy : First create an array with your values(this will go to the number picker) String mValues[] = { "100 " + "\u33A1", "200 " + "\u33A1" }; Now use this method to create

Spanned text in Number picker

别来无恙 提交于 2019-11-29 15:34:19
I have a problem with to show meter m 2 in android. I can use SpannedBuilderString for setText in TextView and it work. The problem is I want to show m 2 in Number Picker like 50 m 2 100 m 2 but Number Picker only show String and I can't. Please help me fix that. Tks everyone. Tamir Abutbul Using Unicode Character makes it very easy : First create an array with your values(this will go to the number picker) String mValues[] = { "100 " + "\u33A1", "200 " + "\u33A1" }; Now use this method to create number picker with custom values: private void setNubmerPicker(NumberPicker nubmerPicker,String []

How to loop through the spans in a SpannedString or SpannableString in Android

◇◆丶佛笑我妖孽 提交于 2019-11-29 04:18:34
If I have a SpannedString (or SpannableString ) like this SpannableString spannableString = new SpannableString("Hello World!"); ForegroundColorSpan foregroundSpan = new ForegroundColorSpan(Color.RED); BackgroundColorSpan backgroundSpan = new BackgroundColorSpan(Color.YELLOW); spannableString.setSpan(foregroundSpan, 1, 8, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spannableString.setSpan(backgroundSpan, 3, spannableString.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(spannableString); How would I loop through the spans of the resulting String ? Suragch Looping through the spans