0

ListViewaの子行としてa を使用し、ExpandableListActivityそのカスタムを定義しCursorTreeAdapterました。値とビューはコードによって期待どおりに入力されていますが、展開可能なリストの各行 (ListView可変数の項目を含む) は部分的にしか表示されません (最初の 2 つの項目のみが表示されます)。

  1. コードをデバッグしているときに、すべての子行 ( ListView) が適切に入力されていること (つまり、10 ~ 15 行)を確認しました。

  2. さらに確認するために、 に変更android:stackFromBottom = "true"しましたListView。今回は、展開可能なアイテムの行ごとに最後の 2 つのアイテムのみが表示されました。

`

public class WorkExpandableListAdapter extends CursorTreeAdapter {

public WorkExpandableListAdapter(Cursor cursor, Context context) { super(cursor, context, true); }

 protected Cursor getChildrenCursor(Cursor groupCursor) { ... return childCursor; }

 @Override
 protected void bindChildView(View view, Context context, Cursor cursor,
   boolean isLastChild) {

  if (!noColumnsToDisplay) {
   int numColumns = workProjection.length + 1; // to skip the _id
   ArrayList<JXTField> jxtFields = new ArrayList<JXTField>();
   for (int i = 1; i < numColumns; i++) {
    jxtFields.add(new JXTField(workProjection[i - 1],
      cursor.getString(cursor
        .getColumnIndex(workProjection[i - 1]))));
   }

//OrderAdapter is simply a customized Array adapter which converts name value pairs into //customized 2 line items

   ArrayAdapter<JXTField> adapter = new OrderAdapter(WorkList.this,
     R.layout.work_view_row, jxtFields);
   ((ListView) view.findViewById(R.id.expandable_child_list))
     .setAdapter(adapter);
  }
 }

 @Override
public View newChildView(Context context, Cursor cursor, boolean isLastChild, ViewGroup parent) {
  return getLayoutInflater().inflate(R.layout.expandable_child_list,null); }

 @Override
protected void bindGroupView(View view, Context context, Cursor cursor, boolean isExpanded) { ... }

 @Override
 protected View newGroupView(Context context, Cursor cursor, boolean isExpanded, ViewGroup parent) {
  return ((TextView) getLayoutInflater().inflate(android.R.layout.simple_expandable_list_item_1, null));
 }
}

`

expandable_child_list.xml

`

<ListView 
    android:id="@+id/expandable_child_listt"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:paddingLeft="20dp"      
    android:layout_weight="2.0"     
    />

`

work_view_row.xml `

<LinearLayout
    android:orientation="vertical"
    android:layout_width="0dip"
    android:layout_weight="1"
    android:layout_height="fill_parent">

    <TextView
        android:id="@+id/work_view_row_top_text"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:gravity="center_vertical"
    />

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1" 
        android:id="@+id/work_view_row_bottom_text"
        android:ellipsize="marquee"
        android:textAppearance="?android:attr/textAppearanceMedium"
    />

</LinearLayout>

`

これは、最初に遭遇したときは簡単に解決できるように見えましたが、あまりにも多くの時間を無駄にした後、達人に頼ります。多分私は非常に明白な何かを見逃していますが、指摘してください。:(

前もって感謝します。

4

1 に答える 1

0

ListViewをオーバーライドするサブクラスを使用して問題を解決できましたonMeasure()

次の 2 つの投稿は、私を正しい方向に向けるのに非常に役立ちました。
1. ScrollView に含まれていない、または ScrollView が無効になっている ListView を作成するにはどうすればよいですか?
2.リスト ビューのサイズを計算するか、完全に展開するように指示する方法

しかし、私はまだこれが肥大化した回避策であると感じており、とそのコンテナ ( ) にが設定されている場合でも、 によって返されるビューが完全に拡張newChildView()できない理由がわかりません。ListViewandroid:layout_height="fill_parent"ListViewLinearLayout

誰かが理由を指摘できるなら、それは素晴らしいことです。
ありがとうございました。

于 2010-12-29T23:41:23.693 に答える