variable を取得し、 title のように最初に 1 回だけ表示する方法はtext1
、text2
それらがtime
特定のデータ グループに対して同じ値を持っているためです。次に、その変数がその特定のデータ グループに対して値を持つ回数だけ変数を表示します。text3
データの書き込みが終了したらtext3
、そのデータ グループについて、クエリはtext1
、text2
および以下time
の新しい値の別のデータ グループの書き込みを開始する必要がありtext3
ます。
これは私のコードです:
public class NapredakActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.first);
String var;
final TextView t = (TextView) findViewById(R.id.textView2);
Intent intent = getIntent();
var=intent.getStringExtra("date");
SQLiteDatabase db = openOrCreateDatabase("Database", MODE_PRIVATE, null);
String q = "SELECT text1 ,text2, text3, time FROM table WHERE time LIKE '"+var+"'";
Cursor c = db.rawQuery(q, null);
if( c.getCount() < 1 ){
c.close();
db.close();
Toast.makeText(NapredakActivity.this, "wrong choice",Toast.LENGTH_LONG).show();
startActivity(new Intent(this,calendar.class));
}
else{
String j="";
c.moveToFirst();
do {
String cm = c.getString(c.getColumnIndex("text1" ));
String cm2 = c.getString(c.getColumnIndex("text2"));
String cm4 = c.getString(c.getColumnIndex("text3"));
String cm3 = c.getString(c.getColumnIndex("time" ));
j = j+"\n"+cm+cm4+cm2+cm3;
} while (c.moveToNext());
t.setText(j);
c.close();
db.close();
} } }