|
private void turn2ListView () {
Intent intent = new Intent ();
intent.setClass(DiaryBookActivity.this, ListViewAct.class);
DiaryBookActivity.this.startActivity(intent);
}
菜单选项调用了以上的方法,要求跳转到以下ListActivity,
public class ListViewAct extends ListActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listview_xml);
System.out.print("cichu");
this.setListAdapter(new ArrayAdapter<String> (this, android.R.layout.simple_list_item_1, this.listFiles()));
}
跳转时候,发生错误,强制退出了。但是,把继承的ListActtvity改成了Activity以后,就可以跳转了,在manifest里如下声明的:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.beak.android.diarybook"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".DiaryBookActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ListViewAct"
>
</activity>
</application>
</manifest> |
|