I have a problem in my Android application. I have a Custom ListView Adapter, but when I launch the application the list does not show any item!
My Code :
import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
public class AccountContents extends Activity {
private ListView ls1;
String username = fourshared.username;
String password = fourshared.password;
private AccountItem[] rootContents;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
rootContents = fourshared.rootContents;
CArrayAdapter adapter = new CArrayAdapter(AccountContents.this, rootContents);
setContentView(R.layout.main);
ls1 = new ListView(AccountContents.this);
ls1.setAdapter(adapter);
}
}
You need to add the list to your activity. To do this, add this line:
and remove: setContentView(R.layout.main);
This will add the list into view, but remove the existing views.
or you can define a list in your xml, and, as mentioned above, find it like this:
and in xml: