2011-07-27 52 views
0

我需要整合的圖形到我的Android應用程序,我想按照這個教程:如何在我的應用程序中繪製圖表?

http://www.jjoe64.com/2011/07/chart-and-graph-library-for-android.html

我試圖把它變成我的活動類,它顯示了相關GraphView一噸的錯誤。以下是代碼片段:

// graph with dynamically genereated horizontal and vertical labels 
GraphView graphView = new GraphView( 
    this // context 
    , new GraphViewData[] { 
    new GraphViewData(1, 2.0d) 
    , new GraphViewData(2, 1.5d) 
    , new GraphViewData(2.5, 3.0d) // another frequency 
    , new GraphViewData(3, 2.5d) 
    , new GraphViewData(4, 1.0d) 
    , new GraphViewData(5, 3.0d) 
    } // data 
    , "GraphViewDemo" // heading 
    , null // dynamic labels 
    , null // dynamic labels 
); 
LinearLayout layout = (LinearLayout) findViewById(R.id.graph1); 
layout.addView(graphView); 

回答

0

你應該把它放在你的你的活動onCreate方法後調用的setContentView方法。

0

這圖書館的問題,因爲沒有的Javadoc,你必須弄清楚如何通過閱讀源代碼來使用它。您可能會收到編制與GraphViewData錯誤,因爲你應該明確地導入該類嵌入GraphView類中:

import com.jjoe64.graphview.GraphView.GraphViewData; 

你也不能有黑色文本,白色背景的彩色方案,而不必「黑客攻擊的源代碼」 。它假定你只需要淺色文本,黑色背景圖。

0

您應該使用AchartEngine AchartEngine

其良好的做任何類型的圖表和圖形的android..it可能對你有幫助...!

相關問題