navotera navotera - 6 months ago 39
Android Question

show progress dialog status android

I have code to show status of Progress Dialog (so i can cancel it later)
but why it always return false ? Can someone suggest me for anything i m doing wrong. Sorry this kind of newbie question. Thanks anyway

public class MainActivity extends AppCompatActivity {


public ProgressDialog mProgressdialog ;





public void getData(View view)
{
//AsyncTaskRunner runner = new AsyncTaskRunner();
// runner.execute();
mProgressdialog = new ProgressDialog(this);
mProgressdialog.show(this, "Loading", "Wait while loading...", false, true);

//this just always return false
System.out.println(mprogressdialog.isShowing());


//contacting server
connectREST();
}

Answer

try to show your Progress Dialog like this :

mProgressdialog = new ProgressDialog(MainActivity.this);
mProgressdialog.setTitle("Loading");
mProgressdialog.setMessage("Wait while loading...");
mProgressdialog.setCancelable(true);
mProgressdialog.setIndeterminate(false;)    
mProgressdialog.show();

System.out.println(mProgressdialog.isShowing());