views:

18

answers:

1

based on Hello-ListView turorial in Android, http://developer.android.com/resources/tutorials/views/hello-listview.html

on the

setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES));

had an error because there is no R.layout.list_item

previously i had followed the tutorial, created the file list_item.xml on the res/layout folder

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp">
</TextView>

it doesnt work with different name neither (main_list_view.xml)

this is the complete source

String[] appList;

ListView mainLv;    

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main); 
    appList = this.getResources().getStringArray(R.array.for_main_layout);
    mainLv = (ListView)findViewById(R.id.ListView01); 
    mainLv.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, appList)); //<<
}

Updated! Ah its works now when creating new project! When i use File>new>Android XML File in the first project, it doesnt work, but now in different project, i use file>new>File, maybe is this a possible bug?

A: 

it doesnt seem to be a bug, in new scenario i tried with the xml and it works normaly

So i just create a new project.

But i dont know the first.

Keenan Gebze