Android Programming Tutorials

(Romina) #1
Menus and Messages

if (current.getType().equals("sit_down")) {
types.check(R.id.sit_down);
}
else if (current.getType().equals("take_out")) {
types.check(R.id.take_out);
}
else {
types.check(R.id.delivery);
}


getTabHost().setCurrentTab( 1 );
}
};


class RestaurantAdapter extends ArrayAdapter {
RestaurantAdapter() {
super(LunchList.this, R.layout.row, model);
}


public View getView(int position, View convertView,
ViewGroup parent) {
View row=convertView;
RestaurantHolder holder=null;


if (row==null) {
LayoutInflater inflater=getLayoutInflater();


row=inflater.inflate(R.layout.row, parent, false);
holder=new RestaurantHolder(row);
row.setTag(holder);
}
else {
holder=(RestaurantHolder)row.getTag();
}


holder.populateFrom(model.get(position));


return(row);
}
}


static^ class^ RestaurantHolder^ {
private TextView name=null;
private TextView address=null;
private ImageView icon=null;
private View row=null;


RestaurantHolder(View row) {
this.row=row;


name=(TextView)row.findViewById(R.id.title);
address=(TextView)row.findViewById(R.id.address);
icon=(ImageView)row.findViewById(R.id.icon);
}


66
Free download pdf