samedi 3 janvier 2015

Android: How to start another activity after all views shown


Vote count:

0




I have a stub activity with progress bar and two labels, and another activity, that may do heavy task (initialize sqlite db from xml resources at first start).


I need start second activity after progress bar and labels are shown.


I'm trying



stubLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (progress.getHeight() <= 0 || progress.getWidth() <= 0) return;
if (label1.getHeight() <= 0 || label1.getWidth() <= 0) return;
if (label2.getHeight() <= 0 || label2.getWidth() <= 0) return;

stubLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);

Intent intent = new Intent();
intent.setClass(getApplicationContext(), SongListActivity.class);
startActivity(intent);
}
});


But I see empty screen while heavy activity is starting. What am I doing wrong?



asked 40 secs ago







Android: How to start another activity after all views shown

Aucun commentaire:

Enregistrer un commentaire