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

樣式 EditText 內(nèi)容'即時(shí)'?

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

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

我正在開(kāi)發(fā) Android 中的富文本編輯器.基本上,它具有與 EditText 相關(guān)聯(lián)的粗體、斜體和鏈接按鈕,以更改內(nèi)容的樣式.如果您先選擇要設(shè)置樣式的文本,然后使用以下方法選擇按鈕,我會(huì)很好地工作: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.

我想做的是讓它像富文本編輯器一樣工作,您可以在其中使用按鈕作為切換來(lái)設(shè)置文本樣式,只要您愿意,然后再次單擊切換以停止使用風(fēng)格.因此,如果我想以粗體輸入注意這一點(diǎn)!",我會(huì)單擊B"按鈕,然后開(kāi)始輸入文本,我輸入的所有內(nèi)容都會(huì)變?yōu)榇煮w,直到我單擊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.

關(guān)于如何實(shí)現(xiàn)這一點(diǎn)的任何想法?我希望我已經(jīng)足夠清楚了:)

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

推薦答案

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

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

好的,這只是簡(jiǎn)單的示例代碼.

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);
    }
}

這篇關(guān)于樣式 EditText 內(nèi)容'即時(shí)'?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Cut, copy, paste in android(在android中剪切、復(fù)制、粘貼)
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 位小數(shù)的數(shù)字)
Changing where cursor starts in an expanded EditText(更改光標(biāo)在展開(kāi)的 EditText 中的開(kāi)始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問(wèn)題)
主站蜘蛛池模板: 精品国产乱码久久久久久中文 | 日韩精品一区二区三区 | 久久午夜精品 | 国产欧美一区二区三区在线看蜜臀 | 亚洲少妇综合网 | 久久精品中文 | 欧美一区久久 | 久久aⅴ乱码一区二区三区 亚洲欧美综合精品另类天天更新 | 在线观看久草 | 在线观看你懂的网站 | 欧美久久国产 | 久久久久中文字幕 | 日韩一区二区三区在线观看 | 欧美操操操 | 国产精品久久久久久 | 亚洲国产精品福利 | 国产 欧美 日韩 一区 | 毛片视频免费 | 搞黄网站在线观看 | 国产一区高清 | 一区二区不卡视频 | 久久精品99久久 | 久久精品在线免费视频 | 精品日韩一区二区 | 国产免费一区二区三区 | 欧美性精品 | 中文字幕国产 | 综合久久av | 日本精品一区二区三区四区 | aaaa日韩| 亚洲视频在线播放 | 国产欧美日韩 | 午夜免费观看网站 | 在线观看成年视频 | 亚洲激情一区二区三区 | 97精品国产 | 蜜桃臀av一区二区三区 | 国产精品久久久久久久午夜 | 久久精品在线 | 亚洲视频在线观看免费 | 超碰激情 |