Eclipse 中的 Android 应用程序: 编辑图形布局中未显示的文本

我试图在 Eclipse 中的 Android 应用程序中添加一个文本字段,但随后我将 Plain text选项拖动到图形布局上,底部会显示一条消息。上面写着 呈现期间引发的异常: java.lang. System.arraycopy ([ CI [ CII) V 异常详细信息记录在“窗口”> “显示视图”> “错误日志”中 即使我转到 Window > Show View,也没有错误日志选项。现在整个设计器都没用了,因为在我直接从 xml 中删除 EditText之前,我不能再使用它了。是什么导致了这个错误,我如何修复它?我正在运行最新版本(截至今天,6-30-14)和 Windows8 Pro x64。

以下是我的完整版面代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}" >


<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
android:text="@string/welcome_text" />


<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:ems="10"
android:inputType="text">


<requestFocus />
</EditText>


</RelativeLayout>
90397 次浏览

Check the "Android version to use when rendering layouts" and make sure you're not using a version that ends in "W" for Android Wear (e.g. API 20: Android 4.4W). I don't believe Wear supports EditText.

In both Android Studio and Eclipse, it's the dropdown with the green android in the layout preview's toolbar. You may want to set it explicitly and not allow the IDE to choose the Android version automatically.

I changed my Android version for Android 4.2, but it still not work for me. I tried different solutions found that it only work by deleting Android 4.4W package.

Window > Android SDK Manager > check Android 4.4W(API 20) if it was installed > Delete package

From the Eclipse IDE, just change the API version to use for previewing, as shown in below screenshot. Instead of "Automatically Pick Best", manually select the one which works for you (API 17 worked for me).

enter image description here

I deleted 4.4w from my sdk install pile, which must have slipped past me last time I installed an sdk. Once I removed it it was no longer and option, and eclipse picked an sdk I did have that wasn't W and it worked.

If you are facing this on Android Studio, follow along

1) Uninstall Android 4.4W(API 20) from the SDK Manager

2) Make sure you have Android SDK Build Tools 19.1 installed from the SDK Manager.

3) Edit build.gradle within your app folder. Set the following two values as below

compileSdkVersion 19
buildToolsVersion "19.1"

4) The IDE will prompt you to sync the Gradle file with your project, click Yes.

5) Open your activity file and then change the 'Android version to use when rendering layouts in IDE' to 'API 19'. This is the green colored Android Bot towards the right on the preview window

The W in Android 4.4W suggest wearable devices. Android Wear is a wrist watch and you cannot type anything in it so you cannot use EditText on 4.4W. Change the API to 19 or less or change it to 4.4L

Check it out @ https://developer.android.com/design/wear/index.html

You can change your previewing API version as Jim suggested if u don't want to develop apps for wearable devices.