现在我正在尝试通过自学在 android 中创建图形。在 Google 上进行了一些搜索后,我得到了一些想法。它建议我使用一些库或 jar 文件在 android 上创建图形或图表。明智地我得到了 kichart WinRAR来自此链接的文件。
模拟器运行后,它只是“抱歉您的应用程序已意外停止。请重试。强制关闭”
有人可以帮我解决这个问题吗?请找到我的来源以供参考。
MainActiviy.java
package com.example.z_chart;
import com.kidroid.kichart.ChartActivity;
import com.kidroid.kichart.model.Aitem;
import com.kidroid.kichart.view.LineView;
import android.graphics.Color;
import android.os.Bundle;
public class MainActivity extends ChartActivity
{
LineView lv = null;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String[] arrX = new String[4];
arrX[0] = "2010.1";
arrX[1] = "2010.2";
arrX[2] = "2010.3";
arrX[3] = "2010.4";
float[] arr = new float[4];
arr[0] = 100;
arr[1] = 150;
arr[2] = 380;
arr[3] = 300;
Aitem[] items = new Aitem[1];
items[0] = new Aitem(Color.RED, "Payout", arr);
lv = new LineView(this);
lv.setTitle("Money balance in four months");
lv.setAxisValueX(arrX);
lv.setItems(items);
setContentView(lv);
}}
LOGCAT
08-17 11:08:53.473: W/dalvikvm(345): Unable to resolve superclass of Lcom/example/z_chart/MainActivity; (414)
08-17 11:08:53.473: W/dalvikvm(345): Link of class 'Lcom/example/z_chart/MainActivity;' failed
08-17 11:08:53.523: D/AndroidRuntime(345): Shutting down VM
08-17 11:08:53.523: W/dalvikvm(345): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
08-17 11:08:53.604: E/AndroidRuntime(345): FATAL EXCEPTION: main
08-17 11:08:53.604: E/AndroidRuntime(345): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.z_chart/com.example.z_chart.MainActivity}: java.lang.ClassNotFoundException: com.example.z_chart.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.z_chart-1.apk]
08-17 11:08:53.604: E/AndroidRuntime(345): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
08-17 11:08:53.604: E/AndroidRuntime(345): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
08-17 11:08:53.604: E/AndroidRuntime(345): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
08-17 11:08:53.604: E/AndroidRuntime(345): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
08-17 11:08:53.604: E/AndroidRuntime(345): at android.os.Handler.dispatchMessage(Handler.java:99)
08-17 11:08:53.604: E/AndroidRuntime(345): at android.os.Looper.loop(Looper.java:123)
08-17 11:08:53.604: E/AndroidRuntime(345): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-17 11:08:53.604: E/AndroidRuntime(345): at java.lang.reflect.Method.invokeNative(Native Method)
08-17 11:08:53.604: E/AndroidRuntime(345): at java.lang.reflect.Method.invoke(Method.java:521)
08-17 11:08:53.604: E/AndroidRuntime(345): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-17 11:08:53.604: E/AndroidRuntime(345): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-17 11:08:53.604: E/AndroidRuntime(345): at dalvik.system.NativeStart.main(Native Method)
08-17 11:08:53.604: E/AndroidRuntime(345): Caused by: java.lang.ClassNotFoundException: com.example.z_chart.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.z_chart-1.apk]
08-17 11:08:53.604: E/AndroidRuntime(345): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
08-17 11:08:53.604: E/AndroidRuntime(345): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
08-17 11:08:53.604: E/AndroidRuntime(345): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
08-17 11:08:53.604: E/AndroidRuntime(345): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
08-17 11:08:53.604: E/AndroidRuntime(345): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
08-17 11:08:53.604: E/AndroidRuntime(345): ... 11 more
清单.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.z_chart"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
提前致谢!..