Java Android 空活动和空白活动

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24522148/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 12:44:41  来源:igfitidea点击:

Android Empty Activity and Blank Activity

javaandroidandroid-activity

提问by Ke7in

I am trying to make an android project and there are many types of activities, from there I see blank activity and empty activity.

我正在尝试制作一个 android 项目,并且有多种类型的活动,从那里我看到空白活动和空活动。

Does anyone know the difference between the two?

有谁知道这两者的区别?

Blank activity is not creating main_activity.xml but is created by empty activity.

空白活动不是创建 main_activity.xml,而是由空活动创建。

In empty activity, I am unable to add EditText Field, Does anyone know why I am not able to add it? Error says :

在空活动中,我无法添加 EditText 字段,有谁知道为什么我无法添加它?错误说:

Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V
Exception details are logged in Window > Show View > Error Log

And when I open error log, there is no error

当我打开错误日志时,没有错误

采纳答案by Rafi Kamal

Check which API level you're using for rendering the view. In my case it was API 20 (for Android Wear). I changed it to API 19 and the error is gone.

检查您用于呈现视图的 API 级别。就我而言,它是 API 20(适用于 Android Wear)。我将其更改为 API 19,错误消失了。

enter image description here

在此处输入图片说明

回答by firefly

Blank Activity: this will create a blank activity with just 1 textview. Full Screen Activity: This is typically used by games. This activity hides the status bar and then your activity takes all screen space. Master Detail Flow: This template creates advanced navigation, based on fragments, which will work on both tablets and phones without any change

空白活动:这将创建一个只有 1 个文本视图的空白活动。全屏活动:这通常由游戏使用。此活动会隐藏状态栏,然后您的活动会占用所有屏幕空间。Master Detail Flow:此模板基于片段创建高级导航,无需任何更改即可在平板电脑和手机上使用

回答by PQH

In my case, same to you blank activity don't generate java&layout but empty activity works well. EditText could use with API20, API21. (BTW blank activity worked well with previous installed).

在我的情况下,与您相同的空白活动不会生成 java&layout 但空活动效果很好。EditText 可以与 API20、API21 一起使用。(顺便说一句,空白活动与以前安装的效果很好)。