久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

樣式 EditText 內容'即時'?

Style EditText content #39;on the fly#39;?(樣式 EditText 內容即時?)
本文介紹了樣式 EditText 內容'即時'?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我正在開發 Android 中的富文本編輯器.基本上,它具有與 EditText 相關聯的粗體、斜體和鏈接按鈕,以更改內容的樣式.如果您先選擇要設置樣式的文本,然后使用以下方法選擇按鈕,我會很好地工作:http://developer.android.com/guide/appendix/faq/commontasks.html#selectingtext.

I'm working on a rich text editor in Android. Basically it has bold, italics and link buttons that are tied to an EditText to change the style of the content. I have it working great if you select the text you want to style first, and then select the button using this method: http://developer.android.com/guide/appendix/faq/commontasks.html#selectingtext.

我想做的是讓它像富文本編輯器一樣工作,您可以在其中使用按鈕作為切換來設置文本樣式,只要您愿意,然后再次單擊切換以停止使用風格.因此,如果我想以粗體輸入注意這一點!",我會單擊B"按鈕,然后開始輸入文本,我輸入的所有內容都會變為粗體,直到我單擊B"' 按鈕.

What I'm trying to do is have it work like a rich text editor, where you can use the buttons as a toggle to style the text for as long as you'd like, then click the toggle again to stop using the style. So if I wanted to type 'Pay attention to this!' in bold, I would click the 'B' button, then start typing the text and everything I type would be bold until I click the 'B' button again.

關于如何實現這一點的任何想法?我希望我已經足夠清楚了:)

Any ideas on how to pull this off? I hope I've been clear enough :)

推薦答案

您可以在他們鍵入的每個字符之后使用 TextWatcheraddTextChangedListener() 方法.

You could just update the style after every character that they type using a TextWatcher and the addTextChangedListener() method.

好的,這只是簡單的示例代碼.

Ok, this is just the bare bones example code.

int mStart = -1;

// Bold onClickListener
public void onClick(View view)
{
    if(mStart == -1) mStart = mEditText.getText().length();
    else mStart = -1;
}

// TextWatcher
onTextChanged(CharSequence s, int start, int before, int count)
{
    if(mStart > 0)
    {
        int end = mEditText.getText().length();
        mEditText.getText().setSpan(new StyleSpan(android.graphics.Typeface.BOLD), mStart, end - mStart, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}

這篇關于樣式 EditText 內容'即時'?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Cut, copy, paste in android(在android中剪切、復制、粘貼)
android EditText blends into background(android EditText 融入背景)
Change Line Color of EditText - Android(更改 EditText 的線條顏色 - Android)
EditText showing numbers with 2 decimals at all times(EditText 始終顯示帶 2 位小數的數字)
Changing where cursor starts in an expanded EditText(更改光標在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: 人人做人人澡人人爽欧美 | 国产精品污www一区二区三区 | 亚洲欧美国产视频 | 成人国产精品久久 | 伊人艹| 欧美日韩国产在线观看 | 免费视频成人国产精品网站 | 欧美a√ | 偷拍自拍网站 | av电影一区| 中文字幕爱爱视频 | 欧美性大战久久久久久久蜜臀 | 亚洲综合久久久 | 精品一级 | 欧美成人第一页 | 黄色av网站在线观看 | 一区视频在线免费观看 | 成人免费观看视频 | 伊人国产精品 | 国产精品美女久久久久久免费 | 国产精品国产精品国产专区不片 | 国产精品久久久久久吹潮 | 精品国产乱码久久久久久中文 | 久久久久久久久精 | 国产精品福利网站 | a级黄色网 | www久久久| 日韩欧美国产精品一区 | 欧美日韩在线不卡 | 在线婷婷 | 97精品超碰一区二区三区 | www国产精 | 欧美精品一区二区三区在线 | 涩爱av一区二区三区 | 欧美精品v国产精品v日韩精品 | 99re国产精品 | 91视频18 | 午夜在线视频 | 桃花av在线 | 日本不卡一区 | 黄色三级毛片 |