我的第一次应用程序活动发生错误。错误是:“应用程序意外停止”
我的第一个 xml 活动是 visit_record.xml
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
我为此活动创建的类是:visit_record.java
public class visit_record extends ListActivity {
static final String[] LIST = new String[] {"My Task", "Task Execution", "Non-Ticket Task"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, R.layout.visit_record,LIST));
ListView listView = getListView();
listView.setTextFilterEnabled(true);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// When clicked, show a toast with the TextView text
Intent intent;
switch (position) {
case 0:
intent= new Intent(visit_record.this, My_Task.class);
startActivity(intent);
break;
case 1:
intent=new Intent(visit_record.this, task_execution.class);
startActivity(intent);
break;
case 2:
intent=new Intent(visit_record.this, non_ticket_task.class);
startActivity(intent);
break;
default:
break;
}}
});
}}
请指导我为什么它会出错而不是在手机中运行应用程序。