[英]problems with R - ANDROID
当我创建一个名为“ main.xml”的布局时:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/button" />
<Spinner
android:id="@+id/spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
当我去主要创建一个按钮时,“ button =(Button)findViewById(R.id.button);”我遇到一个错误,我在R.id中找不到该按钮,并且对于微调框,id在其中不存在R.id
请帮我
您可能导入了错误的R版本。存在两个版本:存在于android.R中的静态R类,然后还有yourPackageName.R。 如果导入前者,则不会找到您的ID。
确保在drawable或assets文件夹中没有大写字母,空格或破折号的文件,图片等。 只需使用旧的小写字母即可。 另外,尝试清理您的项目。 转到项目>清理。 然后重新启动Eclipse。 希望这可以帮助。 另外,如果不先保存,eclipse不会协调XML文件中的任何更改。 添加按钮后,请确保保存。
尝试验证XML文件中没有错误,而不是尝试清理项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.