imageview と textview で動的な行を作成しようとしています。このようなもの:
|_| textview
したがって、私の質問は、xml ファイルを使用せずに、同じ行に Java ソースの imageview の近くに textview を配置できるかどうかです。
これは私のコードです:
TableLayout table = (TableLayout)findViewById(R.id.table);
db.open();
Cursor c5 = db.getAllCodes();
if (c5.moveToFirst())
{
do{
//rows
TableRow tr = new TableRow(this);
tr.setClickable(true);
tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
TextView title = new TextView(this);
title.setTextColor(Color.BLACK);
title.setTextSize(20);
//TextView text = new TextView(this);
//TextView stamp = new TextView(this);
title.setText(c5.getString(6));
//text.setText(c5.getString(1));
//stamp.setText(c5.getString(2));
//tr.addView(iv);
tr.addView(title);
//tr.addView(text);
//tr.addView(stamp);
//add row to layout
getLayoutInflater().inflate(R.layout.image, table, true);
table.addView(tr,new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
}
while (c5.moveToNext());}
db.close();
このコードの結果、2 つの異なる行が作成されます。1 つは画像、もう 1 つはテキストビューです。