とボタンに基づいてListView
を含むActivity
があります。 ボタンをクリックすると、行の高さが大きくなります。リストビューの行の高さをコードに設定
TextView tvRow = (TextView) findViewById(R.id.tvRow);
tvRow.setHeight(20);
が、それは、リストの最初の行だけが変更されます。 私はボタンOnClick
に、このためにTextView
高さを使用することにしました。
私はAdapter
さんgetView
方法で高さを変更することができます。
TextView tvRow = (TextView) view.findViewById(R.id.tvRow);
tvRow.setHeight(20);
が、それは私が必要な機能ではありません。ボタンOnClick
でこれが必要です。
変更するにはListView
ボタンをタップして行の高さを調整しますか? たぶんトリック:) ありがとうございました。
UPDATE:
は@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
view = lInflater.inflate(R.layout.itemF, parent, false);
}
...
final LayoutParams params = view.getLayoutParams();
if (params == null) {
view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, mRowHeight));
}else {
params.height = mRowHeight; }
return view;
ディスプレイのリストはちょうどこれを無視し、その行の幅がまま:私はSimpleCursorAdapter
すべてで、このコードはBaseAdapter
方法getView
では正常に動作しますが、入れ
同じ。なにが問題ですか?
UPDATE:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llRow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:id="@+id/cbBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/llRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="5dp" >
<TextView
android:id="@+id/tvName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Наименование фирмы"
android:textAllCaps="true"
android:textSize="14dp" />
<TextView
android:id="@+id/tvAddr"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Адрес фирмы"
android:textSize="10dp" />
</LinearLayout>
ボタンをクリックすると、すべての行が大きくなりますか? – CaseyB
コードの2番目の部分は最初の部分と同じですが、これは誤植ですか? – Gix
はい、すべての行を同じサイズにしたいと思います。 – Foenix