开发者

how to show the difference between the completed tasks and runnig tasks in a listview using seperators in android

开发者 https://www.devze.com 2023-03-29 18:47 出处:网络
i have a list of tasks, in which at a time only one task is running .i want t开发者_运维问答o show the running task at the top and completed tasks at the bottom and show the difference between them by

i have a list of tasks, in which at a time only one task is running .i want t开发者_运维问答o show the running task at the top and completed tasks at the bottom and show the difference between them by using the seperator . how can i achieve this. please help me

Thanks in advance.


This really depends on how you're running tasks and how you're displaying a list (ListView I presume?). If you're running a task through something like an AsyncTask and a ListView, you should do something as follows:

  1. Make each item in the ListView represent a Task object (something you've created).
  2. Each Task object should have, in its class definition, a boolean flag that is initially false. This boolean flag will represent whether the Task is finished.
  3. Make sure that the Task object has a toString() method, since a ListView works by invoking the toString() method of each of its items. In your scenario, this will probably be a String representing the name of the Task.
  4. When the AsyncTask finishes its execution, set the boolean flag mentioned before to true.
  5. Have two ListViews that stack on each other with a bottom border for the top one (or top border for the bottom one). When a Task object's boolean flag is true, move it to the bottom (or top) ListView, depending on which ListView represents the "finished" list of Tasks.

I hope this helped. Not sure if this is the standard way to do it, but this is how I would do it off the top of my head.

0

精彩评论

暂无评论...
验证码 换一张
取 消