Beginner Android why is “id” is “Unknown member” with R.id?

后端 未结 5 1035
无人及你
无人及你 2021-01-16 09:54

I\'m sure this is something dead simple as it\'s my first android app with code (the hello world example I did was just assigning a value to a string in XML). My problem is

5条回答
  •  难免孤独
    2021-01-16 10:03

    The R class is code-generated for you by the Android build tools when you build your project. This means there are four possibilities:

    1. You have not tried building the project yet, in which case, try that.

    2. Eclipse doesn't think it needs to build the project for some reason -- try Project > Clean from the Eclipse menu (only relevant if you are using Eclipse, of course).

    3. There is some bug in your manifest or one of your resources that is preventing R from being built. There should be Eclipse error indicators for this.

    4. You do not have an android:id attribute in your layout, and therefore there is no R.id available.

提交回复
热议问题