Draw a pie grath with achartEngine from values in Preference xml

Katherinehqr

New Member
I am trying to draw a pie from values stored in an XML preference file. I have 2 values, x y and need to draw a pie from this values. It does not pass the variables through the class. If I put integers instead of x and y, the graph is working perfectly, but I cannot pass the x and y as variables.How can get this working?\[code\]public class MGraphPie extends Activity{ public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); String x = preferences.getString("amountx", "DEFAULT"); String y = preferences.getString("amounty", "DEFAULT");}public Intent getIntent (Context context) { int[] values = {x, y}; CategorySeries series = new CategorySeries("Pe"); int k = 0; for (int value: values) { series.add("Section " + ++k, value); } int[] colors = new int[] { Color.CYAN, Color.RED }; DefaultRenderer renderer = new DefaultRenderer(); for (int color : colors) { SimpleSeriesRenderer r = new SimpleSeriesRenderer(); r.setColor(color); renderer.addSeriesRenderer(r); } Intent intent = ChartFactory.getPieChartIntent(context, series, renderer, "PLEAaa"); return intent;}\[/code\]
 
Back
Top