Tuesday, 29 January 2013

Initialize the Progress Bar | Android Tutorial pdf

Initialize the Progress Bar

For this application, rather than use a ProgressBar widget, we will use the progress bar feature of the Activity window. This will put a progress bar in the title bar, rather than clutter up our layouts.
This requires a bit of initialization. Specifically, we need to add a line to onCreate() that will request this feature be activated. We have to do this before calling setContentView(), so we add it right after chaining to the superclass:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.main);
name=(EditText)findViewById(R.id.name);
address=(EditText)findViewById(R.id.addr);
notes=(EditText)findViewById(R.id.notes);
types=(RadioGroup)findViewById(R.id.types);
Button save=(Button)findViewById(R.id.save);
save.setOnClickListener(onSave);
ListView list=(ListView)findViewById(R.id.restaurants);
adapter=new RestaurantAdapter();
list.setAdapter(adapter);
TabHost.TabSpec spec=getTabHost().newTabSpec("tag1");
spec.setContent(R.id.restaurants);
spec.setIndicator("List", getResources()
.getDrawable(R.drawable.list));
getTabHost().addTab(spec);
spec=getTabHost().newTabSpec("tag2");
spec.setContent(R.id.details);
spec.setIndicator("Details", getResources()
.getDrawable(R.drawable.restaurant));
getTabHost().addTab(spec);
getTabHost().setCurrentTab(0);
list.setOnItemClickListener(onListClick);
}

Also, add another data member, an int named progress.

No comments: