views:

57

answers:

2

Hi I am new in Android. Could anyone tell me pls whats the wrong with the following code:

public class ListApp extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TextView lText = new TextView(this);
    lText.setId(0);       

    ListView lView = new ListView(this);
    String[] lStr = new String[]{"AA","BB", "CC"};
    ArrayAdapter lAdap = new ArrayAdapter(this,lText.getId(),lStr);
    lView.setAdapter(lAdap);
    lView.setFocusableInTouchMode(true);        

    setContentView(lView);
}

}

A: 
public class ListApp extends ListActivity
Kevin Bradshaw
Could I add ListView form Activity. I don't want to inherit from ListActiviy. Is it possible?
ashraf
A: 

Make a layout XML file with your listview and use findViewById to set it's adapter after first setting the content view to your layout

schwiz