J'ai un problème avec mon application Android. La vue est normalement chargée lorsque la tâche asynchrone est commentée. Lorsque, je le décommente, l'activité ne montre/ne charge pas la vue. L'activité est vide ...Pourquoi mon RelativeLayout n'est pas affiché lors de l'appel de AsyncTask?
XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:indeterminate="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"/>
</RelativeLayout>
Java
public class ActivitySplash extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
new AsyncDownloadJson(this).execute("https://my-api-url.com").get();
}
}
Pouvez-vous me expliquer pourquoi? Merci.
Vous devez montrer votre point de vue dans le onPostExecute de Async Tâche. –
A quoi ressemble votre 'AsyncDownloadJson' et n'appelle pas' get() ', sinon votre thread d'interface utilisateur se bloquera. –
Sans le 'get()', il lancera uniquement la tâche AsyncTask sans afficher l'interface utilisateur. Comment afficher la vue et attendre le résultat AsyncTask? – Mathieu