Using the HelloListView example it provides code for making a quick toast notification based on what the user clicks on in your application. I have a list I display that when an item is clicked I would like to display associated information.
My application displays a List of Tasks (custom class) by subject in a very simple ListView.
The ListView is just 1 TextView object with the Tasks Subject as it’s content.
When a task’s subject is clicked I would like to show other information about that task. To keep it simple the task should have an AccountNumber associated with it (integer value). I would like to display that.
The most direct method to do this I think is to display my list of tasks by subject then when a user clicks on a subject I could search my Task List for a task that has that subject and pull out the account number then. This has it’s holes of course. Most obviously what about tasks with the same subject?
Any tips?
Some more information on my code:
Classes:
Task – A single task, has things like start date, end date, subject, account number of the client the task is for
TaskList – A List of Task objects with functions wrapped supporting a list of Task objects
I display a list of tasks in a ListView. Right now I am only displaying a task’s subject. I want a toast notification to pop up the account number of the Task object they just clicked on.
Override the list adapter class. Save all your ‘tasks’ as objects and just display the portion (‘subject’) you want when the adapter is queried for a specific item. Then you can trap the onClick like you do now and display whatever segment of the corresponding object you want.
EDIT: Its explained better here.