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

2.3 上帶有完成 SoftInput 操作標(biāo)簽的多行 EditText

Multiline EditText with Done SoftInput Action Label on 2.3(2.3 上帶有完成 SoftInput 操作標(biāo)簽的多行 EditText)
本文介紹了2.3 上帶有完成 SoftInput 操作標(biāo)簽的多行 EditText的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

有沒有辦法在 Android 2.3 上顯示多行 EditText 并使用 IME 操作標(biāo)簽完成"?

Is there a way to have a Multi-Line EditText present and use the IME Action Label "Done" on Android 2.3?

在 Android 2.2 中這不是問題,輸入按鈕顯示 IME 操作標(biāo)簽完成"(android:imeActionLabel="actionDone"),并在單擊時(shí)關(guān)閉軟輸入.

In Android 2.2 this is not a problem, the enter button shows the IME Action Label "Done" (android:imeActionLabel="actionDone"), and dismisses Soft Input when clicked.

在為多行配置 EditText 時(shí),Android 2.3 移除了為軟輸入鍵盤顯示完成"操作的功能.

When configuring an EditText for multi-line, Android 2.3 removes the ability to show the "Done" action for the Soft Input keyboard.

我已經(jīng)設(shè)法通過使用 KeyListener 來改變軟輸入回車按鈕的行為,但是回車按鈕看起來仍然像回車鍵.

I have managed to alter the behaviour of the Soft Input enter button by using a KeyListener, however the enter button still looks like an enter key.

這里是EditText

<EditText
        android:id="@+id/Comment"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="0dp"
        android:lines="3"
        android:maxLines="3"
        android:minLines="3"
        android:maxLength="60"
        android:scrollHorizontally="false"
        android:hint="hint"
        android:gravity="top|left"
        android:textColor="#888"
        android:textSize="14dp"
        />
<!-- android:inputType="text" will kill the multiline on 2.3! -->
<!-- android:imeOptions="actionDone" switches to a "t9" like soft input -->

當(dāng)我在活動(dòng)中加載設(shè)置內(nèi)容視圖后檢查 inputType 值時(shí),它顯示為:

When I check the inputType value after loading setting the content view in the activity, it shows up as:

inputType = 0x20001

這是:

  • class = TYPE_CLASS_TEXT |TYPE_TEXT_VARIATION_NORMAL
  • 標(biāo)志 = InputType.TYPE_TEXT_FLAG_MULTI_LINE

推薦答案

嗯,重新閱讀了 TextViewEditorInfo 文檔后,已經(jīng)清楚平臺(tái)將強(qiáng)制 IME_FLAG_NO_ENTER_ACTION 進(jìn)行多行文本視圖.

Well, after re-reading the TextView and EditorInfo docs, it has become clear that the platform is going to force IME_FLAG_NO_ENTER_ACTION for multi-line text views.

請注意,TextView 會(huì)自動(dòng)在多行上為您設(shè)置此標(biāo)志文本視圖.

Note that TextView will automatically set this flag for you on multi-line text views.

我的解決方案是繼承 EditText 并在讓平臺(tái)配置它們后調(diào)整 IME 選項(xiàng):

My solution is to subclass EditText and adjust the IME options after letting the platform configure them:

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    InputConnection connection = super.onCreateInputConnection(outAttrs);
    int imeActions = outAttrs.imeOptions&EditorInfo.IME_MASK_ACTION;
    if ((imeActions&EditorInfo.IME_ACTION_DONE) != 0) {
        // clear the existing action
        outAttrs.imeOptions ^= imeActions;
        // set the DONE action
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_DONE;
    }
    if ((outAttrs.imeOptions&EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
        outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
    }
    return connection;
}

在上面,我也強(qiáng)制 IME_ACTION_DONE,即使這可以通過繁瑣的布局配置來實(shí)現(xiàn).

In the above, I'm forcing IME_ACTION_DONE too, even though that can be achieved through tedious layout configuration.

這篇關(guān)于2.3 上帶有完成 SoftInput 操作標(biāo)簽的多行 EditText的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本選擇處理程序單擊事件上的粘貼/替換菜單彈出)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測向左或向右滑動(dòng)?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉(zhuǎn)對話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點(diǎn)擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設(shè)置為僅接受 Android 中的數(shù)值?)
Contact Bubble EditText(聯(lián)系氣泡編輯文本)
主站蜘蛛池模板: 偷拍自拍网址 | 日韩欧美在线不卡 | 蜜臀av日日欢夜夜爽一区 | 一区在线视频 | 久久久久国产一区二区三区 | 午夜精品久久久久久久星辰影院 | 蜜臀网| 青青草一区二区三区 | 成人欧美一区二区三区黑人孕妇 | 成人免费淫片aa视频免费 | 国产97在线视频 | 中文字幕视频一区 | 免费人成在线观看网站 | 欧美精品在线一区 | 久久亚洲精品视频 | 精品国产乱码久久久久久丨区2区 | 亚洲精品视频导航 | 欧美小视频在线观看 | 97视频精品 | 欧美精品一区二区三区四区 在线 | 一级做受毛片免费大片 | 成人免费在线视频 | 欧洲精品一区 | 一区二区三区视频在线免费观看 | 国产精品视频综合 | av中文天堂 | 欧美精品乱码久久久久久按摩 | www国产成人免费观看视频,深夜成人网 | 色狠狠一区 | 国产精品视频久久 | 国产精品一区二区久久 | 国产精品毛片 | 黄色91在线 | 91 在线 | 欧美精品a∨在线观看不卡 国产精品久久国产精品 | 国产亚洲精品久久久久久牛牛 | 成人免费激情视频 | 日本亚洲精品成人欧美一区 | 欧美日韩福利 | 午夜免费福利影院 | 欧区一欧区二欧区三免费 |