-1

I am working on ListView. My list-view get data from server on run time.i want to disable my list-view specific item when it getting data from server and should enable after getting this data.i don't want to use progressBar. currently i am using the following code to disable the list item.

@Override
public boolean isEnabled(int Id) {
    return false;
}

but don't know how to enable is again because the above method always return false when i call it.please tell me how can i do that?

Thank in advance.

Numan Ahmad
  • 157
  • 1
  • 4
  • 14
  • While getting data from server, do you want to disable specific list item or every list item? The solution mentioned in my answer will help to disable click on all listitem while you are fetching the data from the server. – Ravi Bhatt Sep 30 '13 at 11:30

2 Answers2

0

How about adding the list view to its parent only after the data is loaded? perhaps you use some place-holder, a fragment, or a frame.

Steelight
  • 3,347
  • 1
  • 20
  • 17
  • i am using holder and frame. how can i do that may you please give me a example? – Numan Ahmad Sep 30 '13 at 10:25
  • See here for examples: http://stackoverflow.com/questions/6661261/how-to-add-dynamic-content-to-lineary-layout-programmatically-in-my-case – Steelight Oct 01 '13 at 13:32
0

Simply use boolean. Set that boolean variable false until it downloads the data from server. Set it true when data fetching task is completed. Do reset the flag each time when you request for data.

And in you onItemClickListener wrap the code inside the if condition having that boolean variable. Simply the best. :)

Ravi Bhatt
  • 1,930
  • 1
  • 14
  • 27
  • i am using this method to disable the list item but dont know how to enable the item. @Override public boolean isEnabled(int Id) { return false; } because the above method always return false when i call it. – Numan Ahmad Sep 30 '13 at 11:08