Challenge: Progress


#1

Here is my solution to the progress indicator challenge.

1. fragment_locatr.xml
Add an indeterminate progress indicator
android:id="@+id/indeterminateBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_centerInParent=“true”

2. create variable
private ProgressBar mProgressBar;

3. onCreateView(…)
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

mProgressBar = (ProgressBar) v.findViewById(R.id.indeterminateBar);

}

4. add to SearchTask class
@Override
protected void onPreExecute() {
mProgressBar.setVisibility(View.VISIBLE);
}

@Override
protected void onPostExecute(Void result) {

mProgressBar.setVisibility(View.INVISIBLE);
}

All should be OK - too easy.

Cheers
Wayne


#2

I put mProgressBar.setVisibility(View.VISIBLE); in private void findImage() because it will show progress bar immediately