Android Programming Tutorials

(Romina) #1
Life and Times

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);
}


@Override
public void onPause() {
super.onPause();


isActive.set(false);
}


@Override
public void onResume() {
super.onResume();


isActive.set(true);


if (progress> 0 ) {
startWork();
}
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {


82
Free download pdf