私は実際に非常に簡単なことを試みていますが、androidとjavaは私の人生を容易にしません。アイデアは、テーブルレイアウトで指定された子までスクロールすることです。
Layoutinflaterを使用して、次のようにテーブルレイアウトにエントリを追加しています。
TableLayout tl = (TableLayout)findViewById(R.id.myTableLayout3);
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.element_news, null);
TextView firstname = (TextView) itemView.findViewById(R.id.tvname);
firstname.setText(FN + " " + iLN);
TextView date = (TextView) itemView.findViewById(R.id.tvdate);
date.setText(newPD);
TextView post = (TextView) itemView.findViewById(R.id.tvpost);
post.setText(c.getString(iP));
post.setFocusable(true);
tl.addView(itemView, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
テーブルレイアウトにgetChildAt()を使用しようとしましたが、子を取得しましたが、子を使用すると、すべて「0」が返されます。
サンプルコード:
LinearLayout row = (LinearLayout) tl.getChildAt(1);
TextView tv = (TextView) row.getChildAt(1);
tv.requestFocus();
Log.w("news", Integer.toString(tv.getHeight()));
TextView Heightの場合、複数の行が含まれ、requestfocus()も機能しませんが、「0」を返します。
では、テーブルレイアウトで子までスクロールするにはどうすればよいですか?
助けてくれてありがとう。