1

I'm developing an app with a list that should show the name, phone and e-mail addresses of users previously registered on a sqlite database. In each row will also have two buttons.

Something like this:

ListFragment:
-------------------- 
[Name 1] 
[Phone 1] 
[E-mail 1] 
[Button 1][Button 2] 
-------------------- 
[Name 2] 
[Phone 2] 
[E-mail 2] 
[Button 1][Button 2] 
-------------------- 
... (and so on) ...

where the button 1 will make a call and the button 2 will send an email to person. detail, these buttons are clickables ImageView.

I managed to create the XML correctly.

And I know I will need to implement a Custom ArrayAdapter with data from my SQLite database.

I really need to know what is the BEST WAY to implement a Custom ArrayAdapter with data from SQLite ??? I saw so many different ways that I'm totally confused.

please can someone help me with this? if there is a tutorial that explains in detail how to do this, I thank you very much.

Melk Lima
  • 35
  • 6
  • "And I know I will need to implement a Custom ArrayAdapter with data from my SQLite database." no, you don't need any ArrayAdapter, what you need is a SimpleCursorAdapter – pskink Sep 08 '14 at 23:42
  • I've tried with SimpleCursorAdapter. but does not work because the SimpleCursorAdapter does not allow to implement actions to the buttons. – Melk Lima Sep 08 '14 at 23:54
  • [This](http://www.vogella.com/tutorials/AndroidSQLite/article.html) is the tutorial I used when getting up to speed on Android Lists and SQLite. I agree with @pskink that what you need is probably a SimpleCursorAdapter, rather than an ArrayAdapter. – emerssso Sep 09 '14 at 00:04
  • I tried now with SimpleCursorAdapter. but it did not work. displays users' information, but I can not make the buttons work. remembering that my main goal is that when clicking on the first button call the phone number of row in the list and when clicking on the second button send an e-mail to that user. – Melk Lima Sep 09 '14 at 01:10
  • ie multiple clickable parts with different actions to peform in listfragment – Melk Lima Sep 09 '14 at 01:16
  • I used this tutorial to build the layout. but I'm having trouble building the logic. difficulty making the buttons work. remembering that the data comes from the SQLite database. http://wiresareobsolete.com/2011/08/clickable-zones-in-listview-items/ – Melk Lima Sep 09 '14 at 01:32
  • these examples also helped me a lot: 1- http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/ 2- http://androidtuts4u.blogspot.com.br/2013/02/android-list-view-using-custom-adapter.html?m=1 – Melk Lima Sep 10 '14 at 17:05

1 Answers1

0

It looks like this question has the answers you're looking for. You might also try the links in the accepted answer in this question.

Basically, it looks like what you want to do is:

  1. Create a custom descendant of SimpleCursorAdapter
  2. Override getView
    1. Handle inflation of your row using your custom view
    2. Set OnClickListeners for each button
Community
  • 1
  • 1
emerssso
  • 2,376
  • 18
  • 24