简体   繁体   中英

Trouble Saving ID to Resource File

I have been working on an Android Application project recently, and I've notice that some of my code IDs within a XML file will not register within the R file, and I have not been able to access the IDs within my classes. The code within the XML file will look like:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView android:layout_height="250dp"
android:layout_gravity="center"
android:src="@drawable/icon" 
android:id="@+id/ivReturnedPic" 
android:layout_width="250dp"></ImageView>

<ImageButton android:layout_height="wrap_content" 
android:src="@drawable/icon" 
android:id="@+id/ibTakePic" 
android:layout_width="125dp"
android:layout_gravity="center"></ImageButton>

<Button android:text="Set Wallpaper" 
android:id="@+id/bSetWall" 
android:layout_width="125dp" 
android:layout_height="wrap_content"
android:layout_gravity="center"></Button>

</LinearLayout>

None of theses IDs will register within the resource file.

There's problem in your xml that's why R is not being generated automatically

Remove one of extra </LinearLayout>

您必须确保图像“ icon.png”或“ icon.jpg”位于res / drawable文件夹下。

android:src="@drawable/icon" 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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