大家好日子。有人可以告诉我如何从0
检索数据到=COUNTIFS(B10:B152,"Installs",D10:N152,"Done")
?我提到了Android::Data are not retrieving to EditText field through Database,但它对我不起作用..
DisplayData.java
SQLite
UpdateDetails.java
editText
Force.java
private void BuildTable(String names,String date1)
{
final String name = names;
final String date=date1;
sqlcon.open();
Cursor c = sqlcon.readEntry(name);
int rows = c.getCount();
int cols = c.getColumnCount();
c.moveToFirst();
TableRow rowDayLabels=new TableRow(this);
TextView weather=new TextView(this);
weather.setText("Weather");
weather.setTypeface(Typeface.SERIF, Typeface.BOLD);
TextView dater=new TextView(this);
dater.setText("Date");
dater.setTypeface(Typeface.SERIF, Typeface.BOLD);
TextView status=new TextView(this);
status.setText("Status");
status.setTypeface(Typeface.SERIF, Typeface.BOLD);
TextView timeIn=new TextView(this);
timeIn.setText("Time In");
timeIn.setTypeface(Typeface.SERIF, Typeface.BOLD);
TextView timeOut=new TextView(this);
timeOut.setText("Time Out");
timeOut.setTypeface(Typeface.SERIF, Typeface.BOLD);
rowDayLabels.addView(weather);
rowDayLabels.addView(dater);
rowDayLabels.addView(status);
rowDayLabels.addView(timeIn);
rowDayLabels.addView(timeOut);
table_layout.addView(rowDayLabels);
// outer for loop
for (int i = 0; i < rows; i++) {
TableRow row = new TableRow(this);
row.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
// inner for loop
for (int j = 0; j < cols; j++) {
TextView tv = new TextView(this);
tv.setLayoutParams(new TableRow.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
));
// tv.setBackgroundResource(R.drawable.cell_shape);
tv.setGravity(Gravity.CENTER);
tv.setTextSize(18);
tv.setPadding(0, 5, 0, 5);
tv.setText(c.getString(j));
row.addView(tv);
row.setBackgroundColor(Color.GREEN);
row.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(DisplayData.this, UpdatePage.class);
intent.putExtra("name", name);
intent.putExtra("date",date);
startActivity(intent);
}
});
}
c.moveToNext();
table_layout.addView(row);
}
sqlcon.close();
}
}
我错过了什么吗?请告诉我!任何建议都会很棒。感谢
答案 0 :(得分:0)
如果您希望光标中只返回一行,则在执行操作之前不应立即调用moveTofirst和moveToNext。您将通过立即调用这些函数移动到游标中的第二行。我的猜测是你的光标只有一行而你的代码在while循环中没有被执行。错误可能在这里
if (c != null) {
c.moveToFirst();
while (c.moveToNext()) {
Info I = new Info();
}
}
你应该做这样的事情
if (c != null) {
while (c.moveToNext()) {
Info I = new Info();
}
}