I'm new here. Let me know if I'm asking the question the wrong way or if I need to clarify this more.
I'm creating an Android app and I'm using fragments in my code (ie 4 tabs that can slide). I'm trying to add a bar to show a percentage of how much the user has used. I thought the best option would be a progress bar but I cant seem to get it to work.
Here's my code for the fragment I want to add the bar to;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class UserFragment extends Fragment {
private ProgressDialog progress;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_calls, container, false);
progress = new ProgressDialog(this);
return rootView;
}
public void open(View view){
progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progress.setIndeterminate(true);
progress.show();
final int totalProgressTime = 100;
final Thread t = new Thread(){
@Override
public void run(){
int jumpTime = 0;
while(jumpTime < totalProgressTime){
try {
sleep(200);
jumpTime += 5;
progress.setProgress(jumpTime);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
};
t.start();
}
} I followed a couple of tutorials online but I kept getting errors saying "the constructor progress dialog is undefined". I understand that I need some kind of context object but I'm lost on how to go about doing this. If any of ye could give me help on this, I'd greatly appreciate it. Thanks