Привет, у меня есть такая проблема. У меня есть ListView
на клик, мне нужно сделать фоновое задание, поэтому мне нужно показать ProgressBar
. Так что я бы то вроде этогоAndroid show progeress bar
ListView list = (ListView) findViewById(R.id.list);
list.setVisibility(View.INVISIBLE);
ProgressBar bar = (ProgressBar) findViewById(R.id.progress_bar);
bar.setVisibility(View.VISIBLE);
FutureTask<City> task = new FutureTask<City>(new getWeather(city));
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.submit(task);
City city1 = null;
try{
city1 = task.get();
}catch (Exception e){
e.printStackTrace();
}
executorService.shutdown();
//City city1 = City.getInstance(city);
list.setVisibility(View.VISIBLE);
bar.setVisibility(View.INVISIBLE);
и моя задача:
public class getWeather implements Callable<City> {
String city;
public getWeather(String c) {
city = c;
}
@Override
public City call() throws Exception {
TimeUnit.SECONDS.sleep(2);
City city1 = new City();
Bundle bundle = new Bundle();
bundle.putString(City.CITY, city);
city1.setArguments(bundle);
return city1;
}
}
Но мой интерфейс не меняется, я вижу это: 09-29 11:20:10.455 29977-29977/com.example.mike.myapplication I/Choreographer﹕ Skipped 119 frames! The application may be doing too much work on its main thread.
Как я могу это исправить, спасибо.