久久久久久久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(聯系氣泡編輯文本)
主站蜘蛛池模板: 亚洲天天看 | 在线综合网 | 激情久久网 | 免费在线a| 亚洲一区二区在线播放 | 中文在线免费观看 | 在线日韩一区 | 中文字字幕码一二三区 | 亚洲精品社区 | 高清一级片 | 欧美aaaaa| 国产三级在线观看视频 | 五月天婷婷在线观看 | 91精品久久久久久久久久 | 日韩成人一区二区 | 精东影业一区二区三区 | 日韩国产精品视频 | 狠狠做深爱婷婷综合一区 | 日韩午夜精品 | 日韩黄色一级片 | 国产精品免费一区二区三区 | 两性午夜视频 | 亚洲经典一区二区 | 黄色大片免费在线观看 | 欧美精品一二三区 | 精品免费观看 | a视频在线免费观看 | 欧美激情亚洲 | 日韩精品久久久久久久酒店 | 亚洲三级在线 | 精品精品 | 成年人免费视频网站 | 久久精品观看 | 欧美精品在线免费观看 | 夫妻av| 深夜福利网 | 午夜性福利 | 日本加勒比视频 | 色www| 美丽的姑娘观看在线播放 | 五月婷婷激情综合 |