/** Called when the activity is first created. */
TextView selection;
private ListView lv1;
private String lv_arr[]={"Android","iPhone","
"Brazil", "Cote d'Ivoire", "Cameroon",
"Chile", "Costa Rica", "Denmark",
"England", "France", "Germany",
"Ghana", "Greece", "Honduras",
"Italy", "Japan", "Netherlands",
"New Zealand", "Nigeria", "North Korea",
"Paraguay", "Portugal","Serbia",
"Slovakia", "Slovenia", "South Africa",
"South Korea", "Spain", "Switzerland",
"United States", "Uruguay"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(
setContentView(R.layout.main);
selection=(TextView)
lv1=(ListView)findViewById(R.
// By using setAdpater method in listview we an add string array in list.
lv1.setAdapter(new ArrayAdapter
lv1.setTextFilterEnabled(true)
lv1.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView a, View v, int position, long id) {
AlertDialog.Builder adb=new AlertDialog.Builder(
adb.setTitle("
adb.setMessage("Selected Item is = "+lv1.getItemAtPosition(
adb.setPositiveButton("Ok", null);
adb.show();
}
});
}
}
............
main.xml
...............
--
krishnachary
No comments:
Post a Comment