2

ここに私の問題があります。

私はAPI 14に取り組んでおり、Eclipseの助けを借りて「MasterDetailFlow」を作成しました。「ツーペイン」の左側には、いくつかのテキストビューとフラグメントがあります。(私はシンプルにしました)

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:baselineAligned="false"
    android:orientation="horizontal"
    tools:context=".ListActivity" >

    <RelativeLayout
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:layout_weight="27"
        android:orientation="vertical" >
        <TextView
              android:text="toto" 
            />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="textView"/>

          <fragment
              android:id="@+id/fragment1"
              android:name=""
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_below="button"
              />
    </RelativeLayout>
    //the right part of the screen, doesn't matter
    <FrameLayout
         />

</LinearLayout>

フラグメントクラスはそのようなものです

public class MyFragment extends Fragment {
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = null;

        if (mItem != null) {
                if(mItem.isTrue){
                rootView = inflater.inflate(layout1, container, false);
            }else{
                rootView = inflater.inflate(layout2, container, false);
                }
        }
    }
}

ArrayAdapter を使用してリストに項目を動的に追加します。問題は、リストをスクロールする必要がない場合 (リストの高さがフラグメントの高さよりも小さい場合)、すべてが適切に表示されることです。しかし、リストが大きくなり (可視部分は問題ありません)、リストをスクロールすると、layout1 を持つべきいくつかのアイテムが layout2 を持つようになり、逆の場合もあります。これらのアイテムは、最初の要素が隠されているように、奇妙なことに常にジャンクションにあります。アイテムをクリックすると、正常に動作します。たとえば、layout1 である必要がある (しかし、layout2 で表示される) アイテムは、クリックするとアイテム layout1 として機能します。私にはわからないので、それが明確かどうかはわかりません:)

そして、フラグメントにある文字列のリストをlogcatに出力すると、正しい順序で表示されます。では「表示エラー」にしか見えないのですが、どこから来るのでしょうか?

誰かが同様の問題を抱えていますか?問題を知っていますか?

ありがとう。

編集 :

これが私のカスタム ArrayAdapter です。メソッド getItemViewType と getViewTypeCount がありません。それに取り組む必要があります。これまで、DummyItem に格納されたブール値を使用して、タイプ 1 のアイテムかタイプ 2 のアイテムかを判断していました。

    public class CustomArrayAdapter extends ArrayAdapter<DummyItem>
    @Override
        public View getView(int p_position, View p_convertView, ViewGroup p_parent) {
            DummyItem item = data.get(p_position);
            View row = p_convertView;
            if(row==null){
            if(item.isTrue){
            LayoutInflater inflater = ((Activity)m_context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, p_parent, false);
            row.setTag(item);
            TextView label1 = (TextView) row.findViewById(textViewId);
            label1.setText(item.content);


                }else{
                    LayoutInflater inflater = ((Activity)m_context).getLayoutInflater();

                    row = inflater.inflate(R.layout.simple_list_item_activated_1_custom, p_parent, false);
                    TextView label2 = (TextView) row.findViewById(R.id.text1);
                    labelPiece.setText(item.content);


                }


            }else{
            }

            return row;
        }
    }
4

0 に答える 0