0

I want to add a progress bar in a listview when the list loads and if there are no results after the loading is finished I want to add a textVeiw saying the list is empty using the setEmptyView function. I tried using this code to add a progress bar in the list but now luck:

@Override
    protected void onPreExecute() { 
 ProgressBar progress = new ProgressBar(parent);
         progress.setLayoutParams(new LinearLayout.LayoutParams(
         LinearLayout.LayoutParams.WRAP_CONTENT,
         LinearLayout.LayoutParams.WRAP_CONTENT));
        ((ListView) view).setEmptyView(progress);
        super.onPreExecute();
    }

how do I add a progress bar in the list pragmatically without using xml layout to inflate it from? thaks

user1796624
  • 3,665
  • 7
  • 38
  • 65

1 Answers1

0

Try this way,I am not tried but got the reference from this Android – ListView => setEmptyView()

listView.setEmptyView(findViewById(R.id.progressBar));

and let me working or not.

Good Luck.

Rahul Patel
  • 3,823
  • 5
  • 30
  • 46