I just tried to create a listview without list activity and below is the code I used…..
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class ViewNote extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.viewnote);
String names[] = { "One", "Two", "three", "four", "five", "six","seven", "eight", "nine", "ten", "One", "Two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "One", "Two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" };
// Create an ArrayAdapter, that will actually make the Strings above
// appear in the ListView
ListView lv = (ListView) findViewById(R.id.listView1);
lv.setAdapter(new ArrayAdapter<String>(this, R.layout.datalist, names));
}
}

Advertisement


