Code example for ProgressBar

Methods: setIndeterminate, setLayoutParams

0
   protected void onCreate(Bundle savedInstanceState)
   { 
      super.onCreate(savedInstanceState);
 
      // Create a progress bar to display while the list loads 
      ProgressBar progressBar = new ProgressBar(this);
      progressBar.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
      progressBar.setIndeterminate(true);
      getListView().setEmptyView(progressBar);
      getListView().setOnScrollListener(new AwesomeScrollerListener(this, "Europe-TheFinalCountdownTrimmed.mp3"));
 
      // Must add the progress bar to the root of the layout 
      ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
      root.addView(progressBar);
 
      // For the cursor adapter, specify which columns go into which views 
      String[] fromColumns = { ContactsContract.Data.DISPLAY_NAME };
      int[] toViews = { android.R.id.text1 }; // The TextView in simple_list_item_1
 
      // Create an empty adapter we will use to display the loaded data. 
      // We pass null for the cursor, then update it in onLoadFinished()