正在加载一言...
0%

ListView




private ListView listView;

// 数据
private String[] data = { "Apple", "Banana", "Orange", "Watermelon", "Pear", "Grape", "Pineapple", "Strawberry",
"Cherry", "Mango", "Apple", "Banana", "Orange","Watermelon", "Pear", "Grape", "Pineapple", "Strawberry",
        "Cherry", "Mango" };

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test);
    listView = (ListView) findViewById(R.id.list_view);
    // 适配器
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(ActivityTest.this, android.R.layout.simple_list_item_1, data);
    listView.setAdapter(adapter);
}