PieChart with AChartEngine in Android

In my last project I was spending a lot of time looking at charting/graphing libraries for Android. I finally found the awesome AChartEngine but found it very hard to get a simple example working. So here is now a small PieChart example which hopefully can get you started! This example shows a pie chart with income, costs and the difference in a “sub total” sum.

Here’s a quick how to:

  • Extend GraphicalView (class in AChartEngine)
  • Create a getNewInstance method that returns the current class using a custom Renderer and DataSet
  • Create a custom Renderer (defines colors and labels for the chart)
  • Create a custom DataSet (the data maps to the colors you give in the renderer)
  • Profit!

To use this awesome PieChart you’ve now created you need to create a Layout in your xml which you can add the instance to.

Read More

Animated TabHost with slide gesture in Android

So when I was writing my Recept Keeper application i used a TabHost thinking it would have easy access animations and gestures for sliding. Turned out I was wrong and if targeting Android 4 or higher I could have used a PageView/Flipper.

I did however write a custom OnTabChangeListener that which has animations and gestures baked into it. Hope you can find some use of it in your TabHost!

Read More