0

I want to create a view like shown in Image with add and remove ImageButton. On click of any of these will start new activity and get contact detail and set/replace on the clicked index.

screenshot

For Example If I click on 1st green button It will add contact photo and name in 1st row and like-wise for others. I am able to start Activity to get contact information but I experiencing difficulty to manage this layout and set click event on this. Right now I am using 3 different RelativeLayout with all distinct Row Components. and I know It will restrict me to facilitate upto 3.

so here is my questions :

  1. How can I make a UI so that I can grow this list how much I want(for as of now 3 is ok).
  2. How to use add and remove button which will work for there row only.
  3. I also want to display contact number just below the name of contact.
  4. on click of any row will show its detail.

I'll appreciate any suggestion for better UI which can fulfill above requirement. Thanks in advance.

Neuron
  • 5,141
  • 5
  • 38
  • 59
user2376920
  • 242
  • 1
  • 7
  • 19
  • What's the problem with [`ListAdapter`](http://developer.android.com/reference/android/widget/ListAdapter.html)? – m0skit0 Jul 15 '13 at 19:53

1 Answers1

0
  1. How can I make a UI so that I can grow this list how much I want(for as of now 3 is ok).

Use a ListView with a CustomAdapter. This will allow you to show as many rows as necessary. Within the getView() method. Create a separate layout that will be inflated in your Adapter class that will look something like

 <ImageView .../>
 <TextView .../>
 <ImageButton .../>
 <ImageButton .../>

2.How to use add and remove button which will work for there row only.

Set the onClick inside the getView() method of the CustomAdapter you are going to create

Adapter Class

ListView Example

codeMagic
  • 44,549
  • 13
  • 77
  • 93
  • I want to start a new activity to get result on click of `ImageButton` but `StartActivityForResult` and `Intent` is undefined in `getView()`. `Intent intent = new Intent(this, ContactListActivity.class);startActivityForResult(intent, SELECT_CONTACT);` this is what I am doing. – user2376920 Jul 17 '13 at 12:10
  • Add an `onListItemClick()` to your `Activity` from there. If you can't get it to work then you will need to post your code in your OP. You also can set an `onClick()` on your `ImageButton` in your `getView()` – codeMagic Jul 17 '13 at 13:20
  • ok I am able to `startAcitvityForResult()` in `getView()` but `onActivityResult()` defined in adapterclass is not being called. should I move it to Activity class to be called? If yes, how can I identify position of `listItem` that was clicked. – user2376920 Jul 17 '13 at 14:33
  • Create a member variable to the `Activity` and assign it to the position clicked when an item is selected. – codeMagic Jul 17 '13 at 15:52
  • please tell me where I can upload my code to review. I still haven't get my code work as I want. – user2376920 Jul 17 '13 at 19:41
  • You can either post a new question with the relevant code or I guess you can add it to your OP – codeMagic Jul 17 '13 at 19:43
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/33659/discussion-between-user2376920-and-codemagic) – user2376920 Jul 17 '13 at 19:45
  • @user2376920 Sorry, had to step away and work on something. Did you get it working? – codeMagic Jul 17 '13 at 20:26
  • And to answer your question, just a user like you – codeMagic Jul 17 '13 at 20:28