在Android中的EditText上强制全屏

Force FullScreen on EditText in Android(在Android中的EditText上强制全屏)
本文介绍了在Android中的EditText上强制全屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

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

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Change the style of AlertDialog(更改 AlertDialog 的样式)
Pop up dialog in Android home screen(在 Android 主屏幕中弹出对话框)
How to display an existing ListFragment in a DialogFragment(如何在 DialogFragment 中显示现有的 ListFragment)
When to use Android PopupWindow vs Dialog(何时使用 Android PopupWindow vs Dialog)
Android: Close dialog window on touch(Android:触摸时关闭对话框窗口)
Android - Executing a custom listview in a custom dialog properly(Android - 在自定义对话框中正确执行自定义列表视图)