Reputation: 3898
I want to show Horizontal progress bar. In my code i do this with circle Progress bar. I need to show a horizontal Progress bar while searching the Text from a file.
public void search(){
pd.setVisibility(View.VISIBLE);
new Thread(new Runnable() {
@Override
public void run() {
haspmap = Searching(folderNameSelected, langTypeSelected,searchingWord.toLowerCase().trim());
mHandler.post(new Runnable() {
@Override
public void run() {
RecordText.setText(Recordsize+ " Results found");
// int d=haspmap.get(resultRefList).size();
listAdapter = new MylistAdapter(MainActivity.this,
haspmap.get("resultArray"), haspmap.get("suratName"),haspmap.get("ayahnumber"));
SurahList.setAdapter(listAdapter);
hideKeyboard(inputSearch);
inputSearch.setSelection(inputSearch.getText().length());
pd.setVisibility(View.GONE);
searchedList.setVisibility(View.GONE);
}
});
}
}).start();
}
Upvotes: 0
Views: 320
Reputation: 2891
Modify and use this :
int progress_status = 0;
ProgressDialog progressBar = new ProgressDialog(view.getContext());
progressBar.setCancelable(false);
progressBar.setMessage("Please Wait...");
progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressBar.setProgress(0);
progressBar.setMax(100);
progressBar.show();
new Thread(new Runnable() {
public void run() {
if(progress_status < 100) {
loginUser(num, code);
// Update the progress bar
handler.post(new Runnable() {
public void run() {
progressBar.setProgress(progress_status);
}
});
}
}
}).start();
Upvotes: 2
Reputation: 961
By default, the progress bar is a spinning wheel (an indeterminate indicator). To change to a horizontal progress bar, apply the Widget.ProgressBar.Horizontal style, like so:
<ProgressBar
style="@android:style/Widget.ProgressBar.Horizontal"
... />
And please check this link. http://developer.android.com/reference/android/widget/ProgressBar.html
Upvotes: 1