我正在开发 Android 应用程序。当我按下后退按钮时,它说应用程序已停止。
下面是我的代码:
list.setOnItemClickListener( new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long arg3) {
switch(position){
case 1 : Intent intent = new Intent(Product.this, Desktop.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivityForResult(intent, 1);
break;
case 2 : Intent intent1 = new Intent(Product.this, Notebook.class);
intent1.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivityForResult(intent1, 2);
break;
default : break;
}
}
});
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.desktop);
gridView = (GridView) findViewById(R.id.gridView1);
gridView.setAdapter(new ImageAdapter(this, comps));
gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
Toast.makeText(
getApplicationContext(),
((TextView) v.findViewById(R.id.grid_item_label))
.getText(), Toast.LENGTH_SHORT).show();
}
});
}
}
我应该添加什么以便它将转到上一个活动?