文字列の 2 次元配列からテーブルを作成しようとしています。ただし、コードでビューを作成するのが苦手なので、何らかの理由で画像が表示されず、テキストビューが複数行に分割されず、代わりにテキストが切り捨てられます。
また、コード内のすべてのテキストビューにIDを付けました。誰かがテキストビューをクリックすると、そのIDを使用してどの行がクリックされたかを識別できると思っていました。残念ながらそうではありませんでした。
正しい行を識別する良い方法はありますか?
よろしく
for (int current=0; current<cityArr.length; current++) {
TableRow tr = new TableRow(this);
tr.setId(100+current);
tr.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
TextView labelTV = new TextView(this);
labelTV.setId(current);
labelTV.setText(cityArr[current][0]);
labelTV.setTextColor(Color.BLACK);
labelTV.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
tr.addView(labelTV);
ImageView mapView = new ImageView(this);
mapView.setImageResource(R.drawable.list_icon_map);
mapView.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT, 5));
tr.addView(mapView);
tlcity.addView(tr, new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
}