Android Programming Tutorials

(Romina) #1
Getting More Active

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

void populateFrom(Cursor c, RestaurantHelper helper) {
name.setText(helper.getName(c));
address.setText(helper.getAddress(c));

if (helper.getType(c).equals("sit_down")) {
icon.setImageResource(R.drawable.ball_red);
}
else if (helper.getType(c).equals("take_out")) {
icon.setImageResource(R.drawable.ball_yellow);
}
else {
icon.setImageResource(R.drawable.ball_green);
}
}
}
}

Here is one implementation of DetailForm that works with the revised


LunchList:


package apt.tutorial;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.TextView;

public class DetailForm extends Activity {
EditText name=null;
EditText address=null;

129
Free download pdf