@Yano
2016-01-03T13:17:05.000000Z
字数 1047
阅读 2253
Android
http://developer.android.com/reference/android/widget/ListView.html
http://developer.android.com/reference/android/app/ListActivity.html
public class MainActivity extends ListActivity {
List<String> data = new ArrayList<String>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
data.add("1");
data.add("2");
data.add("3");
data.add("4");
setListAdapter(new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_list_item_1, data));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// super.onListItemClick(l, v, position, id);
System.out.println("你单击了:" + data.get(position));
}
}
android.widget.ArrayAdapter.ArrayAdapter<String>(Context context, int textViewResourceId, List<String> objects)