我开发了一个 android 主屏幕,代码看起来是正确的,但是当我运行项目时,我收到以下错误:
java.lang.RuntimeException:
Unable to instantiate activity ComponentInfo{com.matthieu.launcher/
com.matthieu.launcher.DragableSpace}:
java.lang.InstantiationException: com.matthieu.launcher.DragableSpace
这是完整的日志: http: //pastebin.com/iYtYW2W6
代码直接来自 Android Launcher。
可拖动空间: http : //pastebin.com/jpWDtFPF
主要活动:
public class MainActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DragableSpace space = new DragableSpace(this.getApplicationContext());
setContentView(space);
}
}
值文件夹中的attr.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="DragableSpace">
<attr name="default_screen" format="integer"/>
</declare-styleable>
</resources>
三个 xml 文件initial_screen、left_screen和right_screen,除了 id 之外都有相同的代码:
<LinearLayout android:id="@+id/center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
</LinearLayout>
显现:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.matthieu.launcher"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
任何想法如何解决这个问题?