I have a problem with indeterminate progress in android. I have a button and on click of the button the indeterminate progress bar should appear and at the end of the task the progress bar should disappear.
But i am unable to do this.
package com.indeterminate;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.*;
public class IndeterminateProgressBarActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
final ProgressBar pb=new ProgressBar(this);
pb.setVisibility(View.GONE);
Button b =new Button(this);
b.setText("Click to start spinning");
b.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
pb.setVisibility(View.VISIBLE);
// Want to write some code
pb.setVisibility(View.GONE);
// But the progress bar is not shown on the screen
LinearLayout l=new LinearLayout(this);
l.addView(pb);
l.addView(b);
this.setContentView(l);
}
}