android - Classcastexception achartengine -


i trying run achartengine example following link getting classcastexception. unable find source of problem. have added mainactivity.java , manifest.xml. appreciated.

08-09 04:08:10.370: e/androidruntime(3350): fatal exception: main 08-09 04:08:10.370: e/androidruntime(3350): java.lang.classcastexception: org.achartengine.renderer.simpleseriesrenderer cannot cast org.achartengine.renderer.xyseriesrenderer 

mainactivity.java

public class mainactivity extends activity {      private static final int series_nr = 2;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         xymultipleseriesrenderer renderer = gettruitonbarrenderer();         mychartsettings(renderer);         intent intent = chartfactory.getbarchartintent(this,                 gettruitonbardataset(), renderer, type.default);         startactivity(intent);     }      private xymultipleseriesdataset gettruitonbardataset() {         xymultipleseriesdataset dataset = new xymultipleseriesdataset();         final int nr = 4;         random r = new random();         arraylist<string> legendtitles = new arraylist<string>();         legendtitles.add("sales");         legendtitles.add("expenses");         (int = 0; < series_nr; i++) {             categoryseries series = new categoryseries(legendtitles.get(i));             (int k = 0; k < nr; k++) {                 series.add(100 + r.nextint() % 100);             }             dataset.addseries(series.toxyseries());         }         return dataset;     }      public xymultipleseriesrenderer gettruitonbarrenderer() {         xymultipleseriesrenderer renderer = new xymultipleseriesrenderer();         renderer.setaxistitletextsize(16);         renderer.setcharttitletextsize(20);         renderer.setlabelstextsize(15);         renderer.setlegendtextsize(15);         renderer.setmargins(new int[] { 30, 40, 15, 0 });         simpleseriesrenderer r = new simpleseriesrenderer();         r.setcolor(color.blue);         renderer.addseriesrenderer(r);         r = new simpleseriesrenderer();         r.setcolor(color.red);         renderer.addseriesrenderer(r);         return renderer;     }      private void mychartsettings(xymultipleseriesrenderer renderer) {         renderer.setcharttitle("truiton's performance achartengine barchart");         renderer.setxaxismin(0.5);         renderer.setxaxismax(10.5);         renderer.setyaxismin(0);         renderer.setyaxismax(210);         renderer.addxtextlabel(1, "2010");         renderer.addxtextlabel(2, "2011");         renderer.addxtextlabel(3, "2012");         renderer.addxtextlabel(4, "2013");         renderer.setylabelsalign(align.right);         renderer.setbarspacing(0.5);         renderer.setxtitle("years");         renderer.setytitle("performance");         renderer.setshowgrid(true);         renderer.setgridcolor(color.gray);         renderer.setxlabels(0);     } } 

manifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.piegraphicsview"     android:versioncode="1"     android:versionname="1.0" >      <uses-sdk         android:minsdkversion="8"         android:targetsdkversion="17" />      <application         android:allowbackup="true"         android:icon="@drawable/ic_launcher"         android:label="@string/app_name"         android:theme="@style/apptheme" >         <activity             android:name="com.piegraphicsview.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>         <activity android:name="org.achartengine.graphicalactivity" >         </activity>     </application>  </manifest> 

i had similar problem, solution @developeralways said, use xyseriesrenderer instead of simpleseriesrenderer, although there no compile error when use simpleseriesrenderer , works before (achartengine 1.0.0), after updated version 1.2.0, doesn't work anymore.

renderer = new xymultipleseriesrenderer();     simpleseriesrenderer renderbar = new simpleseriesrenderer();     renderbar.setcolor(standardcolor.blue);     renderer.addseriesrenderer(renderbar); 

change to:

renderer = new xymultipleseriesrenderer();     simpleseriesrenderer renderbar = new xyseriesrenderer();     renderbar.setcolor(standardcolor.blue);     renderer.addseriesrenderer(renderbar); 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -