I have Data in ArrayList like:
[android_metadata, test1, test5, test4, test2, test3, test10, test1002, abcd, zxy, re, test1001, testing, test21, test12]
Now i want to Set such data in to the ListView in android. Please help me in this matter. I have seen many Example. but should i have to implement getter setter class to store data and display it into ListView ? I have just to show Just above List of data in to List View and set its ClickEvent. Please Give me Some code to done such implement.
try this code
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class Start extends Activity {
private String[] lv_arr = {};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Get a handle to the list view
ListView lv = (ListView) findViewById(R.id.ListView01);
// Convert ArrayList to array
lv_arr = (String[]) arrayList.toArray();
lv.setAdapter(new ArrayAdapter<String>(Start.this,
android.R.layout.simple_list_item_1, lv_arr));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With