ProgressBar loading;
Button login;

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        loading=(ProgressBar)findViewById(R.id.progressBar1);
        login=(Button)findViewById(R.id.button1);

        }

public void loginAuthenticate(View view)
    {
        loading.setVisibility(View.VISIBLE);
        login.setVisibility(View.INVISIBLE);
        Log.v("EditText", uname = txtUname.getText().toString());
        Log.v("EditText", pass = txtPass.getText().toString());
        initControls();
    }

The initControls() is a function that connects to a website and sends login information. I want to display the progressbar after I click the login button but it doesn't appear immediately. It waits for the initControls() to be done before appearing.

You should use AsyncTask or even better Loader that will let you execute activity on thread and you will be able to start and end loader on methods that do on start and on finish

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.