ListView的简单用法

//布局文件



    




//Acitivity

public class MainActivity extends AppCompatActivity {

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

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ArrayAdapteradapter = new ArrayAdapter(MainActivity.this,android.R.layout.simple_list_item_1,data);
        ListView listView = (ListView)findViewById(R.id.list_view);
        listView.setAdapter(adapter);

    }
}

你可能感兴趣的:(ListView的简单用法)