Muhammad Kashif Nazar
Muhammad Kashif Nazar

Reputation: 23965

R.id not generating for customView

I am trying to define a layout of my custom view with the id cannonView as the following.

<com.myapp.CannonView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/cannonView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent" />

This XML is placed under the layout folder. The problem is that the R.id.cannonView is not generating.

Upvotes: 0

Views: 106

Answers (1)

Muhammad Kashif Nazar
Muhammad Kashif Nazar

Reputation: 23965

I found the answer myself. The problem was that I did not specify the right qualified class name at first. That was the reason ADT did not create this constant in first place.

When I corrected the problem with the right qualified class name, R.id was still not there. I even tried deleting R.java so that ADT regenerated it but that didn't help either.

I had some other compilation errors as well. When I fixed those, R.java generated itself and the id in question was there.

Upvotes: 1

Related Questions