Android Programming Tutorials

(Romina) #1
Menus and Messages

public class LunchList extends TabActivity {
List model=new ArrayList();
RestaurantAdapter adapter=null;
EditText name=null;
EditText address=null;
EditText notes=null;
RadioGroup types=null;
Restaurant current=null;


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
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 boolean onCreateOptionsMenu(Menu menu) {
new MenuInflater(this).inflate(R.menu.option, menu);


return(super.onCreateOptionsMenu(menu));
}


64
Free download pdf