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

2.3 上帶有完成 SoftInput 操作標簽的多行 EditText

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

問題描述

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

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 操作標簽完成"(android:imeActionLabel="actionDone"),并在單擊時關閉軟輸入.

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 時,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.

我已經設法通過使用 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 -->

當我在活動中加載設置內容視圖后檢查 inputType 值時,它顯示為:

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
  • 標志 = InputType.TYPE_TEXT_FLAG_MULTI_LINE

推薦答案

嗯,重新閱讀了 TextViewEditorInfo 文檔后,已經清楚平臺將強制 IME_FLAG_NO_ENTER_ACTION 進行多行文本視圖.

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 會自動在多行上為您設置此標志文本視圖.

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

我的解決方案是繼承 EditText 并在讓平臺配置它們后調整 IME 選項:

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

在上面,我也強制 IME_ACTION_DONE,即使這可以通過繁瑣的布局配置來實現.

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

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

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

相關文檔推薦

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 中檢測向左或向右滑動?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉對話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設置為僅接受 Android 中的數值?)
Contact Bubble EditText(聯系氣泡編輯文本)
主站蜘蛛池模板: 欧美在线色视频 | 日韩午夜在线观看 | 中国美女撒尿txxxxx视频 | 尤物视频在线免费观看 | 国产精品久久久久久久久久久免费看 | 天天弄| 国产精品久久久久久久久久久久久 | 精品视频一区二区三区在线观看 | 欧美四虎 | 国产精品av久久久久久久久久 | 国产二区av | 亚洲国产情侣自拍 | 黄色欧美大片 | 亚洲一区二区视频在线播放 | 免费黄色的视频 | av天天爽 | jdav视频在线观看免费 | 天堂成人av | 国产a区 | 久久久久久综合 | 成人在线黄色 | 羞羞午夜| 国产97视频在线观看 | 日本黄色免费片 | 午夜电影网站 | 日日骚视频 | 美日韩精品 | 综合二区 | 欧美一a一片一级一片 | 欧美一区二区三区久久精品 | 国产成人综合网 | 99r在线| www.三级| 亚洲精品久久久一区二区三区 | 色婷婷久久久久swag精品 | 亚洲欧美日韩精品久久亚洲区 | 91看片网 | 日韩网站在线 | 不卡的av电影 | 欧洲av在线 | 91精品国产乱码久久久久久 |