为什么ImageView的类没有发现? [英] Why the ImageView class is not found?

查看:267
本文介绍了为什么ImageView的类没有发现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的麻烦与在main.xml中的文件插入的ImageView,创造了第一个Android应用程序(静音切换模式从PDFAndroid.Application.Development.for.For.Dummies),当我去图形布局,图像不显示自己并出现此错误:下面的类不能被找到: - ImageView的(更改为android.widget.ImageView,修复构建路径,编辑XML)

i'm having troubles with creating the first android app (Silent Toggle Mode from the pdf "Android.Application.Development.for.For.Dummies" ) with inserting an Imageview in the main.xml file, when I go to the graphical layout, the image isn't showing itself and this error appears:"The following classes could not be found: - ImageView (Change to android.widget.ImageView, Fix Build Path, Edit XML)"

这是我的XML code

this is my xml code

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:contentDescription="@string/hello_world"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <EditText android:id="@+id/edit_message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="@string/edit_message" />

<ImageView 
    android:id="@+id/phone_icon"
    android:contentDescription="@string/description"
    android:layout_width="wrap_content"
    android:scaleType="fitXY"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/phone_on" />

<Button
    android:id="@+id/toggleButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/ToggleSilentMode" />

</LinearLayout>

感谢

推荐答案

这是一个问题,我也可以跨最近运行。内容有点误导性的错误给我,并让我难住了今天上午约30分钟。这并不是说Android无法找到类。它是,它是具有导入麻烦图象源文件

This is one issue that I have also run across recently. It was sort of a misleading error to me and kept me stumped for around 30 minutes this morning. It isn't that Android cannot find the class. It is that it is having trouble importing the image source file.

现在,它是很难找到的图像的原因是因为我的源图像没有复制到该目录正确。我选择了从另一个文件夹目录中的源文件拖动到合适的位置。在这个过程中,它没有复制文件超过正常。或者,它复制过来的只是一个链接到其他资源。

Now the reason that it is having trouble finding the image is because I did not copy the source image into the directory correctly. I have chosen to drag the source file from another folder directory into the appropriate locations. In the process, it did not copy the file over properly. Or it copied it over as just a link to the other resource.

因此​​Android不知道做什么用的资源,并引发了奇怪的错误。为了解决这个问题,你需要删除旧的图像源,然后他们与自己等同的直接完全拷贝替换。那么你应该看到这个错误消失和应用程序从XML布局code按预期工作。

As a result Android does not know what to do with the resource and throws that odd error. In order to resolve this problem, you need to delete the old image sources and then replace them with direct full copies of their equivalents. Then you should see this error go away and the application working as expected from the xml layout code.

这篇关于为什么ImageView的类没有发现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆