我目前正在开发一个使用 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上强制全屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!