0

I'm new in the forum and new in android development. I searched all over internet and around stackoverflow but I can't get an practical answer to my issues. I want to know your opinions about the best approach (handlers, async tasks, etc....) to my application. I have:

**1 - A button that when is clicked must show a list (the data is obtained parsin an html response)

2 - While the list isn't loaded the application must show a "Loading" dialog.**

Now I can load de list when I click on the button, but sometimes (depending on the internet connecxtion) it can take to long and I want to show the Loading progress dialog. I tried to implement AsyncTasks but win the method onPostExecute the dialog was closed but the list wasn't shown on the UI despite it was with correct data.

Can anyone help me with the best approach? Thank you very much.

  • "but the list wasn't shown on the UI despite it was with correct data." If the list has the correct data and the dialog closed at the right time, it sounds like you only need to call `notifyDataSetChanged()`. Or is there something else? – Sam Nov 27 '12 at 21:02
  • 2
    Welcome to SO. If you post some of the relevant code it would be easier to get help. Always post some code when possible so we can see what you have tried and where the problem may be. – codeMagic Nov 27 '12 at 21:08

1 Answers1

0

You have two obvious solutions here you can choose from:

1) Put a ProgressBar within your Layout XML and have it set to View.GONE until the button is pressed and then change to View.VISIBLE, changing to View.GONE again on finish.

2) Have a separate Layout XML with a more details loading view and use setContentView to switch between the both during requests.

I often go with the View.GONE ProgressBar approach

Rawkode
  • 21,990
  • 5
  • 38
  • 45