問題描述
我目前正在開發一個使用 Samsung Galaxy Tab 2 作為設備的應用程序.
I am currently developing an app with Samsung Galaxy Tab 2 as my device.
我在 XML 中的代碼是:
My Code in the XML is:
<EditText
android:id="@+id/analysis_text"
style="@style/icon_text"
android:imeOptions="actionDone"
android:inputType="textMultiLine"
android:onClick="onBtnClicked"
/>
當此代碼執行時,全屏數據輸入模式(提取模式)僅在某些情況下自動觸發.
When this code executes, the full screen data entry mode (Extract Mode) is triggered automatically only in certain situations.
我希望我的用戶在此控件中編輯文本時獲得完整的數據輸入屏幕,無論控件的屏幕或位置如何.
I would like my users to get a full data entry screen while editing text in this control, regardless of the screen or positioning of the control.
這個問題的另一種說法:無論內容是什么,如何在我的活動中為 EditText 框強制全屏數據輸入模式?
Another rephrase of this question: How do I force full screen data entry mode for EditText boxes in my activity no matter what the content is?
推薦答案
我解決了這個問題,并沒有真正解決,但找到了有效的解決方法.
I solved this issue, not really solved, but found a valid work-around.
解決方法是我設計了一個文本編輯器(看起來類似于全屏 UI),并在單擊每個 EditBox
es 時觸發新的 UI 活動(使用 startActivityForResult()
以便在完成后將控制權交還給調用活動),并在完成編輯后將文本傳輸回主屏幕.
The workaround is that I designed a text editor (which looks similar to the fullscreen UI) and on click of each of those EditBox
es the new UI activity is triggerred (with the startActivityForResult()
so that once they are completed control is handed back to the calling activity) and after completion of edit the text is transferred back into the main screen.
我還確保那些轉移控制權的框不會獲得焦點,以便它們立即將控制權轉移到新 UI.
I also ensured that those boxes which transfer the control do not take focus so that they immediately transfer control to the new UI.
通過這種方式,我已經能夠實現一個取消按鈕,它現在實際上允許用戶返回而不保存他意外所做的更改.
This way I have been able to implement a cancel button, which now actually allows the user to go back without saving the changes he accidentally makes.
我對新想法持開放態度,但這對我很有用.
I am open to new ideas, but this has worked for me.
Activity
中的代碼:
public void onBtnClicked(View v) {
EditText current_text_box = (EditText) v;
Intent intent = new Intent(ObservationActivity.this,
TexteditorActivity.class);
intent.putExtra("start_text", current_text_box.getText().toString());
intent.putExtra("start_position", current_text_box.getSelectionStart());
startActivityForResult(intent, v.getId());
}
XML 中的代碼:
<EditText
android:id="@+id/observation_text"
style="@style/icon_text"
android:focusable="false"
android:imeOptions="flagNoExtractUi"
android:inputType="textMultiLine"
android:onClick="onBtnClicked" >
</EditText>
要創建我使用代碼的全屏 UI,您可以使用任何類似 (http://android-richtexteditor.googlecode.com/)
To create the full screen UI I used code, you can use any like (http://android-richtexteditor.googlecode.com/)
這篇關于在Android中的EditText上強制全屏的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!