Create id for a new Listview?

Asked

Viewed 88 times

1

I have the following problem, I already have a listview and I want to create another, but is giving the following error:

 <ListView
        android:id="@android:id/listView" <----- ***Error: No resource found that matches the given name (at 'id' with value '@android:id/listView').***
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    </ListView>
  • 1

    remove the "@android:id/listview" prefix and replace with "@+id/listview" and try again

  • 1

    That’s right, thank you :)

  • Good! I answered with the explanation

1 answer

2


Using the prefix @android:, indicates that you are trying to reference a resource directly from the imported android SDK in your project.

Following the documentation:

@[<nome_do_pacote>:]<tipo_resource>/<nome_resource>

<nome_do_pacote> is the name of the package that Resource is allocated to. You do not need to specify if Resource is from the same package as your project.

<tipo_resource> is a subclass of the file R of the resuorce type

<nome_resource> or is the name of your Source (without the extension) or the attribute android:name element in XML

I mean, instead of @android:id/listView, place @+id/listView and it will work!

  • 1

    vc can tell me if variables and methods with the same name more in different class (in the same package) generate conflict and make the application stop running?

  • 1

    If you have equal ID’s in different XML’s and Classes, there is no problem! In fact, the SDK itself does this. You will find several ID’s like title for example, but of distinct files

  • Okay, I thought that some methods with the same name were making the application stop... you know what can bring a halt in the application?

  • 1

    There are several reasons for this! Ask a question by placing your error stacktrace so that we can help you

  • Actually does not point out any error, I asked a question here... It only has some unused import warnings. Only when it is time to run, when I click on the button that takes the application to Listview to run.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.