我想以表格格式排列我的 sqlite 数据。现在,我正在将数据检索到文本视图。但是它并没有将自己排列在列名下,这看起来很混乱。我希望它至少显示在右列名称下。我尝试在检索数据时在多个 getString() 之间添加多个空格,但似乎没有帮助。!
有人可以帮忙吗??已经谢谢了。
这是代码
public String getData()
{
// TODO Auto-generated method stub
String [] columns = new String[]{KEY_ROW_ID, KEY_KM, KEY_FUEL_QTY, KEY_FUEL_PRICE, KEY_TOTAL_COST, KEY_MILEAGE, KEY_DATE,KEY_TANK_FULL};
fuelCursor = ourDatabase.query(FUEL_DATABASE_TABLE, columns, null, null, null, null, null);
String resultSQL= "";
while(fuelCursor.moveToNext())
{
resultSQL = resultSQL + fuelCursor.getString(0) + " " + fuelCursor.getString(1) + " " + fuelCursor.getString(2) +" "+ fuelCursor.getString(3) + " " + fuelCursor.getString(4) + " " + fuelCursor.getString(5) + " " + fuelCursor.getString(6) + " " + fuelCursor.getString(7) + "\n ";
}
return resultSQL;
}
在 textview 中显示数据:-
TextView tv=(TextView)findViewById(R.id.txtGetFuelInfo);
StoredInfo info = new StoredInfo(this);
Expense fe2= new Expense();
info.open();
String fuelData= info.getData();
info.close();
tv.setText(fuelData);
这是它的样子