0

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();
}
M.ArslanKhan
  • 3,640
  • 8
  • 34
  • 56

3 Answers3

2

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();
rupesh
  • 2,865
  • 4
  • 24
  • 50
2

Best example for progress bar:

  1. Horizontal Progress Bar
  2. Progressbar
  3. NewStyleprogressbar
M D
  • 47,665
  • 9
  • 93
  • 114
1

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

Anatol
  • 941
  • 1
  • 7
  • 13