0

尝试从一项活动(com.intelligent.stocktrader.MyAccount)切换到另一项活动()com.intelligent.stocktrader.SharePerformanceDetails时出现错误。我做错了什么?我的代码没有错误。
以下是日志猫内容:

E/AndroidRuntime(787):致命异常:主要 E/AndroidRuntime(787):java.lang.RuntimeException:无法启动活动 ComponentInfo{com.intelligent.stocktrader/com.intelligent.stocktrader.SharePerformanceDetails}:java.lang.RuntimeException : Parcelable 遇到 IOException 写入可序列化对象 (name = org.achartengine.chart.LineChart) E/AndroidRuntime(787): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955) E/AndroidRuntime(787): at android. app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)

MyAccount 活动 onCreate 在哪里切换活动

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_performance);
    //Bundle extras = getIntent().getExtras();
    //stock_name = extras.getString("stock");
    //new PerformanceDetails().execute();   
    LineGraph line=new LineGraph();
    Intent intent=line.getIntent(getApplicationContext());
    startActivity(intent);
}

线图类

public Intent getIntent(Context context){

    -----------
            -----------
    return intent;
}

LineGraph 类有一个方法将返回一个意图。这是错误传播的地方

4

3 回答 3

1

那是因为您的 Intent 包含无法序列化的 LineChart。你应该从 java.io.Serializable 实现 LineChart。

于 2013-08-01T09:06:00.270 回答
0

尝试这个:

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_performance);
//Bundle extras = getIntent().getExtras();
//stock_name = extras.getString("stock");
//new PerformanceDetails().execute();   
LineGraph line=new LineGraph();
Intent intent=new Intent(getApplicationContext(),SharePerformanceDetails.class); // EDITED
startActivity(intent);

}

于 2013-08-01T09:04:51.087 回答
0

在 onclick() 上使用以下代码它将起作用-

Intent i = new Intent(getApplicationContext(), SecondScreen.class);
StartActivity(i);

要运行我们的应用程序,您应该在 AndroidManifest.xml 文件中输入您的新活动。在标签之间添加新的活动:

<activity android:name=".NewActivityClassName"></activity>
于 2013-08-01T09:01:19.580 回答