简体   繁体   English

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

[英]Android app in Eclipse: Edit text not showing on Graphical layout

I am trying to add a text field onto my Android app in Eclipse, but then I drag the Plain text option on to the graphical layout, a message at the bottom comes up. 我试图在Eclipse中将文本字段添加到我的Android应用程序中,但是随后我将“ Plain text选项拖到图形布局上,出现了底部的消息。 It reads Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V Exception details are logged in Window > Show View > Error Log Even when I go to Window > Show View there is no error log option. 它读取Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V Exception details are logged in Window > Show View > Error Log即使我转到“ Window > Show View ,也没有错误日志选项。 The whole designer is useless now, because I can not use it anymore until I delete the EditText directly from the xml. 整个设计器现在已经没有用了,因为直到直接从xml中删除EditText之前,我再也无法使用它。 What is causing this error, and how do I fix it? 是什么导致此错误,我该如何解决? I am running the latest version (as of today, 6-30-14), and Windows 8 Pro x64. 我正在运行最新版本(截至今天,6月30日至14日)和Windows 8 Pro x64。

Here is my full layout code: 这是我的完整布局代码:

<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>

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 ( eg API 20: Android 4.4W). 检查“渲染布局时要使用的Android版本”,并确保您没有使用Android Wear的以“ W”结尾的版本( 例如 API 20:Android 4.4W)。 I don't believe Wear supports EditText . 我不认为Wear支持EditText

In both Android Studio and Eclipse, it's the dropdown with the green android in the layout preview's toolbar. 在Android Studio和Eclipse中,这都是布局预览工具栏中带有绿色android的下拉列表。 You may want to set it explicitly and not allow the IDE to choose the Android version automatically. 您可能需要显式设置它,并且不允许IDE自动选择Android版本。

From the Eclipse IDE, just change the API version to use for previewing, as shown in below screenshot. 在Eclipse IDE中,只需更改用于预览的API版本,如下面的屏幕快照所示。 Instead of "Automatically Pick Best", manually select the one which works for you (API 17 worked for me). 代替“自动选择最佳”,而是手动选择一个对您有用的工具(API 17对我有用)。

在此处输入图片说明

I changed my Android version for Android 4.2, but it still not work for me. 我将Android版本更改为Android 4.2,但仍然无法使用。 I tried different solutions found that it only work by deleting Android 4.4W package. 我尝试了其他解决方案,发现它只能通过删除Android 4.4W程序包才能工作。

Window > Android SDK Manager > check Android 4.4W(API 20) if it was installed > Delete package 窗口> Android SDK管理器>检查是否安装了Android 4.4W(API 20)>删除程序包

If you are facing this on Android Studio, follow along 如果您在Android Studio上遇到此问题,请继续

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

2) Make sure you have Android SDK Build Tools 19.1 installed from the SDK Manager. 2)确保从SDK Manager安装了Android SDK Build Tools 19.1。

3) Edit build.gradle within your app folder. 3)在您的应用文件夹中编辑build.gradle。 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. 4)IDE将提示您将Gradle文件与您的项目同步,单击“是”。

5) Open your activity file and then change the 'Android version to use when rendering layouts in IDE' to 'API 19'. 5)打开您的活动文件,然后将“在IDE中渲染布局时使用的Android版本”更改为“ API 19”。 This is the green colored Android Bot towards the right on the preview window 这是预览窗口右侧的绿色Android Bot

I deleted 4.4w from my sdk install pile, which must have slipped past me last time I installed an sdk. 我从sdk安装桩中删除了4.4w,上次安装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. 一旦删除它,它就不再是选项,而eclipse选择了我确实没有的sdk,它就可以了。

The W in Android 4.4W suggest wearable devices. Android 4.4W中的W建议可穿戴设备。 Android Wear is a wrist watch and you cannot type anything in it so you cannot use EditText on 4.4W. Android Wear是一款手表,您无法在其中输入任何内容,因此无法在4.4W上使用EditText。 Change the API to 19 or less or change it to 4.4L 将API更改为19以下或将其更改为4.4L

Check it out @ https://developer.android.com/design/wear/index.html 看看@ 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. 如果您不想为可穿戴设备开发应用程序,则可以按照Jim的建议更改预览API版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM