3
我已經在我的主活動類中動態地實現了GraphView。 未顯示結果。 啓動時,活動保持空白。GarphView不工作,空白活動
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//GraphView
int num = 150;
GraphViewData[] data = new GraphViewData[num];
double v=0;
for (int i=0; i<num; i++) {
v += 0.2;
data[i] = new GraphViewData(i, Math.sin(v));
}
GraphView graphView = new LineGraphView(this, "GraphViewDemo");
// add data
GraphViewSeries graphViewSeries=new GraphViewSeries(data);
graphView.addSeries(graphViewSeries);
// set view port, start=2, size=40
graphView.setViewPort(2, 40);
graphView.setScrollable(true);
// optional - activate scaling/zooming
graphView.setScalable(true);
Log.d("2", "closed");
LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
layout.addView(graphView);
//GraphhView
}
我是我想念的東西,但我什麼都沒有得到。
請出示您的佈局xml文件 – appsthatmatter 2014-10-01 10:08:08