I have two string arrays, here s1[] contains a list of names and s2[] contains URL\'s associated with the respective name, now i need to populate ListView, with the names and on
public class MyActivity extends ListActivity{
private ArrayList urls = new ArrayList();
private ArrayList names = new ArrayList();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
urls.add("http://www.google.com");
names.add("google");
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, android.R.id.text1, names);
setListAdapter(adapter);
}
protected void onListItemClick (ListView l, View v, int position, long id){
String url = urls.get(position);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
}