Jan 19, 2017

Array vs ArrayList

*****Array*****

String item[]={"Cupcake","Donut",
            "Eclairs","Froyo","GingerBread","HoneyComb",
            "IceCreamSandWitch","Jellybean","Kitkat",
            "Lollipop", "Marshmallow", "Nougat"};



*****Aray List*****

ArrayList<String> list = new ArrayList<String>();

list.add(textview.getText().toString());
list.add("B");
list.add("C");



*****Array Adapter****

ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,item);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,list);



*****Set Adapter*****
listview.setAdapter(adapter);

No comments:

Post a Comment