Is R.layout.listview is same as R.id.listview

android, android-listview, android-resources

Solution

No Both are different.

R.id.listView1 :-

Represents the id of View which is declared in layout (your XML file) as `android:id="@+id/listView1"`

and

R.layout.listView1 :-

Represents the layout file (xml file) which into `res -> layout` dir

You can do

ListView list= (ListView) findViewById(R.id.listView1);

because ListView is of View family.

But you can't do

ListView list= (ListView) findViewById(R.layout.listView1); 

Problem

I am new to android programming. I have created a `ListView` and its `android:id="@+id/listView1"` ``` ListView list= (ListView) findViewById(R.id.listView1); ListView list= (ListView) findViewById(R.layout.listView1); ``` Will it refer the same ListView? Are there any difference between these two snippets?

Original source