Tim The Learner Tim The Learner - 1 year ago 67
Java Question

How to hide app layout until postexecute

Ok I'm executing two async tasks as soon as I open my app. Currently have a Progress dialog but you can still see the layout in the background.
So the obvious answer would be to not

until the progress dialog is dismissed. But I can't do that as my first async task assigns a video into a view In its post execute and this throws a null pointer exception if the layout has not been set earlier.

protected void onPostExecute(Void result) {
//video is a string file created by doinbackground
card = (VideoView) findViewById(R.id.video);

//Video Loop
card.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {


Answer Source

Inside the layout inside the code and use setVisibity() For example you have to hide a linear layout with id myLayout 1) Set the id in layout xml


2)Now under OnCreate method in your code

LinearLayout linearLayout = (LinearLayout) findViewbyId(R.id.mylayout);

3) user postExecute method

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download