[android-developers] Re: How i get the Selected item from the list Adapter.
join the below group to discuss more http://groups.google.com/group/mobile-application-developers use like this lv=(ListView)findViewById(R.id.ListView01); lv.setChoiceMode(lv.CHOICE_MODE_SINGLE); lv.setAdapter(new ArrayAdapterString(this, android.R.layout.simple_list_item_1 , airport_list)); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { System.out.println(selected item position is = +position ); System.out.println(selected item is =+lv.getItemAtPosition(position)); if(list_selected == arrival) arrival_list_selected=(String) lv.getItemAtPosition (position); else if(list_selected == depature) depature_list_selected=(String) lv.getItemAtPosition (position); if(airport_selectedby.equals(flightschedule)) flight_schedule(); else if(airport_selectedby.equals(flightstatus)) flight_status(); } }); here lv is a listview. On Aug 28, 5:35 pm, ragavendran s sraghav.ra...@gmail.com wrote: i m a beginner for Android development How i get the Selected item from the list Adapter. for example i m having the code: Code: final Spinner spinner = (Spinner) findViewById(R.id.testSpinner); ArrayAdapterString adapter = new ArrayAdapterString(this, android.R.layout.simple_spinner_item, Months); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); /---some code/ static final String[] Months = new String[]{ January,February,March,April,May,June,July,August, September,October,November,December }; public void changeOption(Spinner spinner){ if (spinner.isEnabled()){ spinner.setEnabled(false); } else{ spinner.setEnabled(true); } } Question: In this above code if i selected March from the Dropdown Adapter means then how can i retrieve the Manth March to show in a textview. Please tell me the ANswer... with Regard, Raghav.S --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: How i get the Selected item from the list Adapter.
You can register public abstract void onItemSelected (AdapterView? parent, View view, int position, long id) and to retrieve the selected value from ArrayAdapter.getItem(int position) using the selected position as parameter. On Fri, Aug 28, 2009 at 3:35 PM, ragavendran ssraghav.ra...@gmail.com wrote: i m a beginner for Android development How i get the Selected item from the list Adapter. for example i m having the code: Code: final Spinner spinner = (Spinner) findViewById(R.id.testSpinner); ArrayAdapterString adapter = new ArrayAdapterString(this, android.R.layout.simple_spinner_item, Months); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); /---some code/ static final String[] Months = new String[]{ January,February,March,April,May,June,July,August, September,October,November,December }; public void changeOption(Spinner spinner){ if (spinner.isEnabled()){ spinner.setEnabled(false); } else{ spinner.setEnabled(true); } } Question: In this above code if i selected March from the Dropdown Adapter means then how can i retrieve the Manth March to show in a textview. Please tell me the ANswer... with Regard, Raghav.S -- When I raise my flashing sword, and my hand takes hold on judgment, I will take vengeance upon mine enemies, and I will repay those who haze me. Oh, Lord, raise me to Thy right hand and count me among Thy saints. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: How i get the Selected item from the list Adapter.
Thanks a lot it's really very simple and clear using ContextMenu On Fri, Aug 28, 2009 at 3:45 PM, Sasi Kumarsasikumar.it1...@gmail.com wrote: join the below group to discuss more http://groups.google.com/group/mobile-application-developers use like this lv=(ListView)findViewById(R.id.ListView01); lv.setChoiceMode(lv.CHOICE_MODE_SINGLE); lv.setAdapter(new ArrayAdapterString(this, android.R.layout.simple_list_item_1 , airport_list)); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { System.out.println(selected item position is = +position ); System.out.println(selected item is =+lv.getItemAtPosition(position)); if(list_selected == arrival) arrival_list_selected=(String) lv.getItemAtPosition (position); else if(list_selected == depature) depature_list_selected=(String) lv.getItemAtPosition (position); if(airport_selectedby.equals(flightschedule)) flight_schedule(); else if(airport_selectedby.equals(flightstatus)) flight_status(); } }); here lv is a listview. On Aug 28, 5:35 pm, ragavendran s sraghav.ra...@gmail.com wrote: i m a beginner for Android development How i get the Selected item from the list Adapter. for example i m having the code: Code: final Spinner spinner = (Spinner) findViewById(R.id.testSpinner); ArrayAdapterString adapter = new ArrayAdapterString(this, android.R.layout.simple_spinner_item, Months); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); /---some code/ static final String[] Months = new String[]{ January,February,March,April,May,June,July,August, September,October,November,December }; public void changeOption(Spinner spinner){ if (spinner.isEnabled()){ spinner.setEnabled(false); } else{ spinner.setEnabled(true); } } Question: In this above code if i selected March from the Dropdown Adapter means then how can i retrieve the Manth March to show in a textview. Please tell me the ANswer... with Regard, Raghav.S -- When I raise my flashing sword, and my hand takes hold on judgment, I will take vengeance upon mine enemies, and I will repay those who haze me. Oh, Lord, raise me to Thy right hand and count me among Thy saints. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: How i get the Selected item from the list Adapter.
You can't figure out which item is selected from the adapter. It is the ListView or ListActivity (depending on which you used) that will tell you which is selected. Yusuf Saib Android ·T· · ·Mobile· stick together The views, opinions and statements in this email are those of the author solely in their individual capacity, and do not necessarily represent those of T-Mobile USA, Inc. On Aug 28, 7:23 am, Martin Obreshkov manig...@gmail.com wrote: Thanks a lot it's really very simple and clear using ContextMenu On Fri, Aug 28, 2009 at 3:45 PM, Sasi Kumarsasikumar.it1...@gmail.com wrote: join the below group to discuss more http://groups.google.com/group/mobile-application-developers use like this lv=(ListView)findViewById(R.id.ListView01); lv.setChoiceMode(lv.CHOICE_MODE_SINGLE); lv.setAdapter(new ArrayAdapterString(this, android.R.layout.simple_list_item_1 , airport_list)); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { System.out.println(selected item position is = +position ); System.out.println(selected item is =+lv.getItemAtPosition(position)); if(list_selected == arrival) arrival_list_selected=(String) lv.getItemAtPosition (position); else if(list_selected == depature) depature_list_selected=(String) lv.getItemAtPosition (position); if(airport_selectedby.equals(flightschedule)) flight_schedule(); else if(airport_selectedby.equals(flightstatus)) flight_status(); } }); here lv is a listview. On Aug 28, 5:35 pm, ragavendran s sraghav.ra...@gmail.com wrote: i m a beginner for Android development How i get the Selected item from the list Adapter. for example i m having the code: Code: final Spinner spinner = (Spinner) findViewById(R.id.testSpinner); ArrayAdapterString adapter = new ArrayAdapterString(this, android.R.layout.simple_spinner_item, Months); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_it em); spinner.setAdapter(adapter); /---some code/ static final String[] Months = new String[]{ January,February,March,April,May,June,July,August, September,October,November,December }; public void changeOption(Spinner spinner){ if (spinner.isEnabled()){ spinner.setEnabled(false); } else{ spinner.setEnabled(true); } } Question: In this above code if i selected March from the Dropdown Adapter means then how can i retrieve the Manth March to show in a textview. Please tell me the ANswer... with Regard, Raghav.S -- When I raise my flashing sword, and my hand takes hold on judgment, I will take vengeance upon mine enemies, and I will repay those who haze me. Oh, Lord, raise me to Thy right hand and count me among Thy saints. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---