主要实现从一个activity输入订单,从另一个activity输出。运行到输出activity(QueryActivity)时程序崩溃。
AddActivity:
public class AddActivity extends Activity {
private EditText et1, et2, et3;
private TextView tv1, tv2, tv3;
private Spinner spinner1;
private Button b1;
private ArrayAdapter adapter1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add);
this.setTitle("添加新的订单");
et1 = (EditText) findViewById(R.id.et1);
et2 = (EditText) findViewById(R.id.et2);
et3 = (EditText) findViewById(R.id.et3);
tv1 = (TextView) findViewById(R.id.tv1);
tv2 = (TextView) findViewById(R.id.tv2);
tv3 = (TextView) findViewById(R.id.tv3);
spinner1 = (Spinner) findViewById(R.id.spinner1);
b1 = (Button) findViewById(R.id.ButtonAdd);
adapter1 = ArrayAdapter.createFromResource(this, R.array.food, android.R.layout.simple_spinner_item);
adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(adapter1);
spinner1.setOnItemSelectedListener(new SpinnerXMLSelectedListener());
spinner1.setVisibility(View.VISIBLE);
b1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String number = et1.getText().toString();
String tele = et2.getText().toString();
String address = et3.getText().toString();
String name = spinner1.getSelectedItem().toString();
ContentValues values = new ContentValues();
values.put("name", name);