我是android开发的新手。我需要绘制一个动态图,其中值必须存储在 sqlite 数据库中。我正在使用 jjoe64 graphview 库来绘制它......现在的问题是如何将字符串作为值插入到图中。我已经尝试并寻找解决方案,但仍然找不到完美的解决方案......
代码是这样的: -
import com.jjoe64.graphview.BarGraphView;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.GraphView.GraphViewData;
import com.jjoe64.graphview.GraphViewSeries;
import com.jjoe64.graphview.LineGraphView;
import dev.starmobile.database.MarkAdapter;
import dev.starmobile.database.MarkOpenHelper;
import android.os.Bundle;
import android.app.Activity;
import android.database.sqlite.SQLiteDatabase;
import android.view.Menu;
import android.widget.LinearLayout;
public class GraphActivity extends Activity {
MarkAdapter adapter;
MarkOpenHelper helper;
SQLiteDatabase db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_graph);
adapter = new MarkAdapter(this);
double sem = Double.parseDouble(helper.SEMESTER);
double mark = Double.parseDouble(helper.MARK);
GraphViewSeries markValue = new GraphViewSeries(
new GraphViewData[] {sem,mark });
GraphView myGraphView = new LineGraphView(this // context
, "Performance" // heading
);
myGraphView.addSeries(markValue); // data
LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
layout.addView(myGraphView);
}
数据库中的声明
// public static final String SEMESTER = "STUD_SEM";
// public static final String MARK = "STUD_MARK";