I have one custom list for displaying employee pic and name and i want to navigate to next activity when list item is clicked, In next activity i want to display details of employee dynamically from web service!! how to do that please give some idea or link??
thank you in advance!

- 19
- 4
1 Answers
That's a very broad question which will take a long time to answer. There are a few ways you could do it, but hopefully this short answer will help and at least point you in a direction.
I'm guessing you already have an adapter with a list of all employees (List or whatever) powering your listview. You should create a public method in your adapter to take in the position, and return a unique id referencing your employee. Note a unique id is not necessarily the same as the position of the item.
Here's a crude example:
public int getUniqueId(int position){
Employee employee = mAllItems.get(position);
if(employee != null){
return employee.getUniqueId();
}
//Couldn't find
return 0;
}
Then implement an onItemClickListener on your listview. The method can then call the adapter to retrieve a unique id. This unique ID is what you would pass via intent to your new activity. Your new activity will lookup the employee details and display them.
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
int uniqueId = mAdapter.getUniqueId(position);
if(uniqueId > 0) {
Intent i = new Intent(this, ActivityEmployeeDetails.class);
i.putExtra(ActivityEmployeeDetails.TAG_UNIQUE_ID, uniqueId);
startActivity(i);
}
}
Hope this helps.

- 3,485
- 3
- 20
- 43
-
thanks for your valuable answer, can you guide me on how to access array list values coming from web service in my android code and display them to relative text boxes in activity. P.S- i am using SOAP based web service and getting the values in List array. – AndroidSeeker Dec 10 '14 at 06:38
-
Sorry bud, not really, use REST instead of SOAP: http://stackoverflow.com/a/303500/3009199 – James Dec 10 '14 at 08:45