[android-developers] Re: ListView OnItemClickListener not working
Sorry for the bump but I´m still stuck into this and that is the only feature not ready. Could you guys please give me a hand here? thanks! On 6 set, 14:29, Gabriel Simões gsim...@gmail.com wrote: Hello guys After a long time away, got back to coding on this brazilian independency holiday. What I´m trying to do is to create a list (using a listview) of items (which are views inflated from the same layout) what must be clickable. At first I thought that all I had to do was to add an onItemClickListener to the ListView so if the used clicked on any of the views that composed this Item the listener would react. Well, I was wrong. I´ve tried a lot of things, including setting focus and focusontouchmode off for each of the views that compose the item´s view but it still doesn´t work. Any tips here? Can I archive this result? Oh, also ... this listview is in a dialog and the listener is in the activity that builds the dialog. Hope to hear from you soon. Thanks, Gabriel Simões -- 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
Re: [android-developers] Re: ListView OnItemClickListener not working
Gabriel, This is how it's done: ListView listView = ..whatever; listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView? parent, View view, int position, long id) { do your thing here } }); -- Kostya 07.09.2010 17:39, Gabriel Simões пишет: Sorry for the bump but I´m still stuck into this and that is the only feature not ready. Could you guys please give me a hand here? thanks! On 6 set, 14:29, Gabriel Simõesgsim...@gmail.com wrote: Hello guys After a long time away, got back to coding on this brazilian independency holiday. What I´m trying to do is to create a list (using a listview) of items (which are views inflated from the same layout) what must be clickable. At first I thought that all I had to do was to add an onItemClickListener to the ListView so if the used clicked on any of the views that composed this Item the listener would react. Well, I was wrong. I´ve tried a lot of things, including setting focus and focusontouchmode off for each of the views that compose the item´s view but it still doesn´t work. Any tips here? Can I archive this result? Oh, also ... this listview is in a dialog and the listener is in the activity that builds the dialog. Hope to hear from you soon. Thanks, Gabriel Simões -- Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com -- 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: ListView OnItemClickListener not working
Hey Kostia, Thanks for your reply. I´ve already done it, but the method onItemClick is never called! I´ve read some stuff about focus, onTouchfocus but nothing changed the result. Each item in the listview is a view inflated from a layout which has TextViews and a button (in a relative layout). Any ideas why clicking on an item (view) doesn´t fire onItemClick? Thanks! On 7 set, 11:37, Kostya Vasilyev kmans...@gmail.com wrote: Gabriel, This is how it's done: ListView listView = ..whatever; listView.setOnItemClickListener(new OnItemClickListener() { �...@override public void onItemClick(AdapterView? parent, View view, int position, long id) { do your thing here } }); -- Kostya 07.09.2010 17:39, Gabriel Simões пишет: Sorry for the bump but I´m still stuck into this and that is the only feature not ready. Could you guys please give me a hand here? thanks! On 6 set, 14:29, Gabriel Simõesgsim...@gmail.com wrote: Hello guys After a long time away, got back to coding on this brazilian independency holiday. What I´m trying to do is to create a list (using a listview) of items (which are views inflated from the same layout) what must be clickable. At first I thought that all I had to do was to add an onItemClickListener to the ListView so if the used clicked on any of the views that composed this Item the listener would react. Well, I was wrong. I´ve tried a lot of things, including setting focus and focusontouchmode off for each of the views that compose the item´s view but it still doesn´t work. Any tips here? Can I archive this result? Oh, also ... this listview is in a dialog and the listener is in the activity that builds the dialog. Hope to hear from you soon. Thanks, Gabriel Simões -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- 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
Re: [android-developers] Re: ListView OnItemClickListener not working
Gabriel, For what it's worth, here is my ListItem layout xml: http://pastebin.com/ZUDjF06r And this is the list adapter's getView method: http://pastebin.com/JWt5Wb40 Nothing special here, including any code to mess with view focus. I call setOnItemClickListener before setAdapter in the ListView. -- Kostya 07.09.2010 19:41, Gabriel Simões пишет: Hey Kostia, Thanks for your reply. I´ve already done it, but the method onItemClick is never called! I´ve read some stuff about focus, onTouchfocus but nothing changed the result. Each item in the listview is a view inflated from a layout which has TextViews and a button (in a relative layout). Any ideas why clicking on an item (view) doesn´t fire onItemClick? Thanks! On 7 set, 11:37, Kostya Vasilyevkmans...@gmail.com wrote: Gabriel, This is how it's done: ListView listView = ..whatever; listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView?parent, View view, int position, long id) { do your thing here } }); -- Kostya 07.09.2010 17:39, Gabriel Simões пишет: Sorry for the bump but I´m still stuck into this and that is the only feature not ready. Could you guys please give me a hand here? thanks! On 6 set, 14:29, Gabriel Simõesgsim...@gmail.comwrote: Hello guys After a long time away, got back to coding on this brazilian independency holiday. What I´m trying to do is to create a list (using a listview) of items (which are views inflated from the same layout) what must be clickable. At first I thought that all I had to do was to add an onItemClickListener to the ListView so if the used clicked on any of the views that composed this Item the listener would react. Well, I was wrong. I´ve tried a lot of things, including setting focus and focusontouchmode off for each of the views that compose the item´s view but it still doesn´t work. Any tips here? Can I archive this result? Oh, also ... this listview is in a dialog and the listener is in the activity that builds the dialog. Hope to hear from you soon. Thanks, Gabriel Simões -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com -- 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: ListView OnItemClickListener not working
Tried calling setOnItemClickListener before setAdapter but nothing :( final ListView lvList = (ListView) dialog.findViewById(R.id.lvList); lvList.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView? arg0, View arg1, int arg2, long arg3) { removeDialog(DIALOG_LOAD_ID); } }); lvList.setAdapter(new DBAdapter(this.getApplicationContext())); thanks once again, Gabriel On 7 set, 12:48, Kostya Vasilyev kmans...@gmail.com wrote: Gabriel, For what it's worth, here is my ListItem layout xml: http://pastebin.com/ZUDjF06r And this is the list adapter's getView method: http://pastebin.com/JWt5Wb40 Nothing special here, including any code to mess with view focus. I call setOnItemClickListener before setAdapter in the ListView. -- Kostya 07.09.2010 19:41, Gabriel Simões пишет: Hey Kostia, Thanks for your reply. I´ve already done it, but the method onItemClick is never called! I´ve read some stuff about focus, onTouchfocus but nothing changed the result. Each item in the listview is a view inflated from a layout which has TextViews and a button (in a relative layout). Any ideas why clicking on an item (view) doesn´t fire onItemClick? Thanks! On 7 set, 11:37, Kostya Vasilyevkmans...@gmail.com wrote: Gabriel, This is how it's done: ListView listView = ..whatever; listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView? parent, View view, int position, long id) { do your thing here } }); -- Kostya 07.09.2010 17:39, Gabriel Simões пишет: Sorry for the bump but I´m still stuck into this and that is the only feature not ready. Could you guys please give me a hand here? thanks! On 6 set, 14:29, Gabriel Simõesgsim...@gmail.com wrote: Hello guys After a long time away, got back to coding on this brazilian independency holiday. What I´m trying to do is to create a list (using a listview) of items (which are views inflated from the same layout) what must be clickable. At first I thought that all I had to do was to add an onItemClickListener to the ListView so if the used clicked on any of the views that composed this Item the listener would react. Well, I was wrong. I´ve tried a lot of things, including setting focus and focusontouchmode off for each of the views that compose the item´s view but it still doesn´t work. Any tips here? Can I archive this result? Oh, also ... this listview is in a dialog and the listener is in the activity that builds the dialog. Hope to hear from you soon. Thanks, Gabriel Simões -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- 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
Re: [android-developers] Re: ListView OnItemClickListener not working
Ah, it seems you are using a dialog. I wonder if this makes any difference vs. an activity. -- Kostya 07.09.2010 19:58, Gabriel Simões пишет: Tried calling setOnItemClickListener before setAdapter but nothing :( final ListView lvList = (ListView) dialog.findViewById(R.id.lvList); lvList.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView? arg0, View arg1, int arg2, long arg3) { removeDialog(DIALOG_LOAD_ID); } }); lvList.setAdapter(new DBAdapter(this.getApplicationContext())); thanks once again, Gabriel On 7 set, 12:48, Kostya Vasilyevkmans...@gmail.com wrote: Gabriel, For what it's worth, here is my ListItem layout xml: http://pastebin.com/ZUDjF06r And this is the list adapter's getView method: http://pastebin.com/JWt5Wb40 Nothing special here, including any code to mess with view focus. I call setOnItemClickListener before setAdapter in the ListView. -- Kostya 07.09.2010 19:41, Gabriel Simões пишет: Hey Kostia, Thanks for your reply. I´ve already done it, but the method onItemClick is never called! I´ve read some stuff about focus, onTouchfocus but nothing changed the result. Each item in the listview is a view inflated from a layout which has TextViews and a button (in a relative layout). Any ideas why clicking on an item (view) doesn´t fire onItemClick? Thanks! On 7 set, 11:37, Kostya Vasilyevkmans...@gmail.comwrote: Gabriel, This is how it's done: ListView listView = ..whatever; listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView? parent, View view, int position, long id) { do your thing here } }); -- Kostya 07.09.2010 17:39, Gabriel Simões пишет: Sorry for the bump but I´m still stuck into this and that is the only feature not ready. Could you guys please give me a hand here? thanks! On 6 set, 14:29, Gabriel Simõesgsim...@gmail.com wrote: Hello guys After a long time away, got back to coding on this brazilian independency holiday. What I´m trying to do is to create a list (using a listview) of items (which are views inflated from the same layout) what must be clickable. At first I thought that all I had to do was to add an onItemClickListener to the ListView so if the used clicked on any of the views that composed this Item the listener would react. Well, I was wrong. I´ve tried a lot of things, including setting focus and focusontouchmode off for each of the views that compose the item´s view but it still doesn´t work. Any tips here? Can I archive this result? Oh, also ... this listview is in a dialog and the listener is in the activity that builds the dialog. Hope to hear from you soon. Thanks, Gabriel Simões -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com -- 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: ListView OnItemClickListener not working
yes, I´m asking myself the same Anyone here ever faced this? Thanks On 7 set, 13:05, Kostya Vasilyev kmans...@gmail.com wrote: Ah, it seems you are using a dialog. I wonder if this makes any difference vs. an activity. -- Kostya 07.09.2010 19:58, Gabriel Simões пишет: Tried calling setOnItemClickListener before setAdapter but nothing :( final ListView lvList = (ListView) dialog.findViewById(R.id.lvList); lvList.setOnItemClickListener(new OnItemClickListener(){ �...@override public void onItemClick(AdapterView? arg0, View arg1, int arg2, long arg3) { removeDialog(DIALOG_LOAD_ID); } }); lvList.setAdapter(new DBAdapter(this.getApplicationContext())); thanks once again, Gabriel On 7 set, 12:48, Kostya Vasilyevkmans...@gmail.com wrote: Gabriel, For what it's worth, here is my ListItem layout xml: http://pastebin.com/ZUDjF06r And this is the list adapter's getView method: http://pastebin.com/JWt5Wb40 Nothing special here, including any code to mess with view focus. I call setOnItemClickListener before setAdapter in the ListView. -- Kostya 07.09.2010 19:41, Gabriel Simões пишет: Hey Kostia, Thanks for your reply. I´ve already done it, but the method onItemClick is never called! I´ve read some stuff about focus, onTouchfocus but nothing changed the result. Each item in the listview is a view inflated from a layout which has TextViews and a button (in a relative layout). Any ideas why clicking on an item (view) doesn´t fire onItemClick? Thanks! On 7 set, 11:37, Kostya Vasilyevkmans...@gmail.com wrote: Gabriel, This is how it's done: ListView listView = ..whatever; listView.setOnItemClickListener(new OnItemClickListener() { �...@override public void onItemClick(AdapterView? parent, View view, int position, long id) { do your thing here } }); -- Kostya 07.09.2010 17:39, Gabriel Simões пишет: Sorry for the bump but I´m still stuck into this and that is the only feature not ready. Could you guys please give me a hand here? thanks! On 6 set, 14:29, Gabriel Simõesgsim...@gmail.com wrote: Hello guys After a long time away, got back to coding on this brazilian independency holiday. What I´m trying to do is to create a list (using a listview) of items (which are views inflated from the same layout) what must be clickable. At first I thought that all I had to do was to add an onItemClickListener to the ListView so if the used clicked on any of the views that composed this Item the listener would react. Well, I was wrong. I´ve tried a lot of things, including setting focus and focusontouchmode off for each of the views that compose the item´s view but it still doesn´t work. Any tips here? Can I archive this result? Oh, also ... this listview is in a dialog and the listener is in the activity that builds the dialog. Hope to hear from you soon. Thanks, Gabriel Simões -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- 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
Re: [android-developers] Re: ListView OnItemClickListener not working
On Tue, Sep 7, 2010 at 11:05 AM, Kostya Vasilyev kmans...@gmail.com wrote: Ah, it seems you are using a dialog. I wonder if this makes any difference vs. an activity. Probably. OP, how are you setting up your dialog? If you're doing this method: http://developer.android.com/guide/topics/ui/dialogs.html#AddingAList You should be supplying a click listener as part of the setup, not after the fact. I wouldn't be surprised if the ListView in the dialog is eating the events. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- 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: ListView OnItemClickListener not working
Here is my code: Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.save); dialog.setTitle(Program Saving Center); final ListView lvList = (ListView) dialog.findViewById(R.id.lvList); lvList.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView? arg0, View arg1, int arg2, long arg3){ removeDialog(DIALOG_SAVE_ID); } }); lvList.setAdapter(new DBAdapter(this.getApplicationContext())); I´m stuck on this... On 7 set, 13:59, TreKing treking...@gmail.com wrote: On Tue, Sep 7, 2010 at 11:05 AM, Kostya Vasilyev kmans...@gmail.com wrote: Ah, it seems you are using a dialog. I wonder if this makes any difference vs. an activity. Probably. OP, how are you setting up your dialog? If you're doing this method:http://developer.android.com/guide/topics/ui/dialogs.html#AddingAList You should be supplying a click listener as part of the setup, not after the fact. I wouldn't be surprised if the ListView in the dialog is eating the events. --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- 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
Re: [android-developers] Re: ListView OnItemClickListener not working
2010/9/7 Gabriel Simões gsim...@gmail.com Here is my code: Interesting ... first thing I would do is try using the method in the link I posted to build a Dialog that contains a ListView instead of doing it manually and see if that works. lvList.setAdapter(new DBAdapter(this.getApplicationContext())); Side-note: don't use getApplicationContext(), just use this. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- 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
Re: [android-developers] Re: ListView OnItemClickListener not working
2010/9/7 Gabriel Simões gsim...@gmail.com: Here is my code: Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.save); dialog.setTitle(Program Saving Center); final ListView lvList = (ListView) dialog.findViewById(R.id.lvList); lvList.setOnItemClickListener(new OnItemClickListener(){ �...@override public void onItemClick(AdapterView? arg0, View arg1, int arg2, long arg3){ removeDialog(DIALOG_SAVE_ID); } }); lvList.setAdapter(new DBAdapter(this.getApplicationContext())); I´m stuck on this... Also, delete every occurrence of getApplicationContext() from your code. Never use it. Whatever object you are calling getApplicationContext() on *is* a Context. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training in London: http://skillsmatter.com/go/os-mobile-server -- 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
Re: [android-developers] Re: ListView OnItemClickListener not working
2010/9/7 Gabriel Simões gsim...@gmail.com: Here is my code: Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.save); dialog.setTitle(Program Saving Center); final ListView lvList = (ListView) dialog.findViewById(R.id.lvList); lvList.setOnItemClickListener(new OnItemClickListener(){ �...@override public void onItemClick(AdapterView? arg0, View arg1, int arg2, long arg3){ removeDialog(DIALOG_SAVE_ID); } }); lvList.setAdapter(new DBAdapter(this.getApplicationContext())); I´m stuck on this... Either: -- Use AlertDialog.Builder and setAdapter(), supplying the listener that way, or -- Create a dialog-themed ListActivity -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training in London: http://skillsmatter.com/go/os-mobile-server -- 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: ListView OnItemClickListener not working
If I´m not wrong I can´t inflate a layout on an alertdialog, right? On this Layout I have more than a ListView (buttons and TextViews) so to use an AlertDialog probably is not the best solution for me right now. Mark, thanks for your answers. About the context, I didn´t get it. I thought that when I created a dialog I should pass to it the context of the activity that created it, am I wrong? If I don´t decide to use an alertdialog, is there a way to make it work using a pure dialog? Thank you guys very much! On 7 set, 17:35, Mark Murphy mmur...@commonsware.com wrote: 2010/9/7 Gabriel Simões gsim...@gmail.com: Here is my code: Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.save); dialog.setTitle(Program Saving Center); final ListView lvList = (ListView) dialog.findViewById(R.id.lvList); lvList.setOnItemClickListener(new OnItemClickListener(){ �...@override public void onItemClick(AdapterView? arg0, View arg1, int arg2, long arg3){ removeDialog(DIALOG_SAVE_ID); } }); lvList.setAdapter(new DBAdapter(this.getApplicationContext())); I´m stuck on this... Either: -- Use AlertDialog.Builder and setAdapter(), supplying the listener that way, or -- Create a dialog-themed ListActivity -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy Android Training in London:http://skillsmatter.com/go/os-mobile-server -- 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
Re: [android-developers] Re: ListView OnItemClickListener not working
2010/9/7 Gabriel Simões gsim...@gmail.com: If I´m not wrong I can´t inflate a layout on an alertdialog, right? Sure you can. On this Layout I have more than a ListView (buttons and TextViews) so to use an AlertDialog probably is not the best solution for me right now. That probably should not be a dialog. Use an activity. About the context, I didn´t get it. I thought that when I created a dialog I should pass to it the context of the activity that created it, am I wrong? The Activity *is* a Context. Never call getApplicationContext(). If I don´t decide to use an alertdialog, is there a way to make it work using a pure dialog? Use an activity. Give it Theme.Dialog if you want it to look like a dialog. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training in London: http://skillsmatter.com/go/os-mobile-server -- 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: ListView OnItemClickListener not working
what intrigates me is that the listeners for the buttons work perfectly, plug play. :/ On 7 set, 17:54, Mark Murphy mmur...@commonsware.com wrote: 2010/9/7 Gabriel Simões gsim...@gmail.com: If I´m not wrong I can´t inflate a layout on an alertdialog, right? Sure you can. On this Layout I have more than a ListView (buttons and TextViews) so to use an AlertDialog probably is not the best solution for me right now. That probably should not be a dialog. Use an activity. About the context, I didn´t get it. I thought that when I created a dialog I should pass to it the context of the activity that created it, am I wrong? The Activity *is* a Context. Never call getApplicationContext(). If I don´t decide to use an alertdialog, is there a way to make it work using a pure dialog? Use an activity. Give it Theme.Dialog if you want it to look like a dialog. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy Android Training in London:http://skillsmatter.com/go/os-mobile-server -- 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: ListView OnItemClickListener not working
Guys, Tried changing to an AlertBuilder but got the same result: Builder loadDialog = new AlertDialog.Builder(this); loadDialog.setIcon(R.drawable.load); loadDialog.setTitle(Program Loading Center); loadDialog.setMessage(); View v = View.inflate(this, R.layout.load, null); final ListView lvList = (ListView) v.findViewById(R.id.lvList); lvList.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView? arg0, View arg1, int arg2, long arg3) { removeDialog(DIALOG_LOAD_ID); FlurryAgent.onEvent(Load, null); } }); lvList.setAdapter(new DBAdapter(this)); loadDialog.setView(v); Everything is displayed just as expected but when I the function onItemClick is never fired (clicking on any of the items displayed at lvList, which inflated from the same layout containing textviews and a button, all over a relativelayout). Any other ideas? tnx On 7 set, 18:04, Gabriel Simões gsim...@gmail.com wrote: what intrigates me is that the listeners for the buttons work perfectly, plug play. :/ On 7 set, 17:54, Mark Murphy mmur...@commonsware.com wrote: 2010/9/7 Gabriel Simões gsim...@gmail.com: If I´m not wrong I can´t inflate a layout on an alertdialog, right? Sure you can. On this Layout I have more than a ListView (buttons and TextViews) so to use an AlertDialog probably is not the best solution for me right now. That probably should not be a dialog. Use an activity. About the context, I didn´t get it. I thought that when I created a dialog I should pass to it the context of the activity that created it, am I wrong? The Activity *is* a Context. Never call getApplicationContext(). If I don´t decide to use an alertdialog, is there a way to make it work using a pure dialog? Use an activity. Give it Theme.Dialog if you want it to look like a dialog. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy Android Training in London:http://skillsmatter.com/go/os-mobile-server -- 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: ListView OnItemClickListener not working
and if it helps, this is how I populate my ListView: public View getView(int arg0, View arg1, ViewGroup arg2) { View layout = View.inflate(context, R.layout.program, null); (load views and set their values ...) Button btDelete = (Button) layout.findViewById(R.id.btDelete); btDelete.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { (on click action for a button inside the view that builds each item in the list) } }); return layout; } On 7 set, 18:55, Gabriel Simões gsim...@gmail.com wrote: Guys, Tried changing to an AlertBuilder but got the same result: Builder loadDialog = new AlertDialog.Builder(this); loadDialog.setIcon(R.drawable.load); loadDialog.setTitle(Program Loading Center); loadDialog.setMessage(); View v = View.inflate(this, R.layout.load, null); final ListView lvList = (ListView) v.findViewById(R.id.lvList); lvList.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView? arg0, View arg1, int arg2, long arg3) { removeDialog(DIALOG_LOAD_ID); FlurryAgent.onEvent(Load, null); } }); lvList.setAdapter(new DBAdapter(this)); loadDialog.setView(v); Everything is displayed just as expected but when I the function onItemClick is never fired (clicking on any of the items displayed at lvList, which inflated from the same layout containing textviews and a button, all over a relativelayout). Any other ideas? tnx On 7 set, 18:04, Gabriel Simões gsim...@gmail.com wrote: what intrigates me is that the listeners for the buttons work perfectly, plug play. :/ On 7 set, 17:54, Mark Murphy mmur...@commonsware.com wrote: 2010/9/7 Gabriel Simões gsim...@gmail.com: If I´m not wrong I can´t inflate a layout on an alertdialog, right? Sure you can. On this Layout I have more than a ListView (buttons and TextViews) so to use an AlertDialog probably is not the best solution for me right now. That probably should not be a dialog. Use an activity. About the context, I didn´t get it. I thought that when I created a dialog I should pass to it the context of the activity that created it, am I wrong? The Activity *is* a Context. Never call getApplicationContext(). If I don´t decide to use an alertdialog, is there a way to make it work using a pure dialog? Use an activity. Give it Theme.Dialog if you want it to look like a dialog. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy Android Training in London:http://skillsmatter.com/go/os-mobile-server -- 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: ListView OnItemClickListener not working
Mark, Treking, NEWS!!! Well, I´ve changed some code to try different things on my Adapter and I found out that if I don´t inflate the layout, use a TextView instead, the code works great. The thing is, if the function getView from my AdapterClass returns the View that I have inflated than it doesn´t work. If it returns a TextView, it works (using my old Dialog). What to try next? On 7 set, 19:22, Gabriel Simões gsim...@gmail.com wrote: and if it helps, this is how I populate my ListView: public View getView(int arg0, View arg1, ViewGroup arg2) { View layout = View.inflate(context, R.layout.program, null); (load views and set their values ...) Button btDelete = (Button) layout.findViewById(R.id.btDelete); btDelete.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { (on click action for a button inside the view that builds each item in the list) } }); return layout; } On 7 set, 18:55, Gabriel Simões gsim...@gmail.com wrote: Guys, Tried changing to an AlertBuilder but got the same result: Builder loadDialog = new AlertDialog.Builder(this); loadDialog.setIcon(R.drawable.load); loadDialog.setTitle(Program Loading Center); loadDialog.setMessage(); View v = View.inflate(this, R.layout.load, null); final ListView lvList = (ListView) v.findViewById(R.id.lvList); lvList.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView? arg0, View arg1, int arg2, long arg3) { removeDialog(DIALOG_LOAD_ID); FlurryAgent.onEvent(Load, null); } }); lvList.setAdapter(new DBAdapter(this)); loadDialog.setView(v); Everything is displayed just as expected but when I the function onItemClick is never fired (clicking on any of the items displayed at lvList, which inflated from the same layout containing textviews and a button, all over a relativelayout). Any other ideas? tnx On 7 set, 18:04, Gabriel Simões gsim...@gmail.com wrote: what intrigates me is that the listeners for the buttons work perfectly, plug play. :/ On 7 set, 17:54, Mark Murphy mmur...@commonsware.com wrote: 2010/9/7 Gabriel Simões gsim...@gmail.com: If I´m not wrong I can´t inflate a layout on an alertdialog, right? Sure you can. On this Layout I have more than a ListView (buttons and TextViews) so to use an AlertDialog probably is not the best solution for me right now. That probably should not be a dialog. Use an activity. About the context, I didn´t get it. I thought that when I created a dialog I should pass to it the context of the activity that created it, am I wrong? The Activity *is* a Context. Never call getApplicationContext(). If I don´t decide to use an alertdialog, is there a way to make it work using a pure dialog? Use an activity. Give it Theme.Dialog if you want it to look like a dialog. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy Android Training in London:http://skillsmatter.com/go/os-mobile-server -- 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
Re: [android-developers] Re: ListView OnItemClickListener not working
2010/9/7 Gabriel Simões gsim...@gmail.com The thing is, if the function getView from my AdapterClass returns the View that I have inflated than it doesn´t work. If it returns a TextView, it works (using my old Dialog). Does it work if you click on the TextView portion(s) of your custom view? Have you set the focusable / clickable (don't remember which they are) attributes of your custom view? - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- 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