Hi,

i'm using a ListFragment with an ExpandableListView - which is backed by a 
SimpleCursorTreeAdapter - at the moment and everything was working 
perfectly. I decided at a later stage to switch to the 
support.v4.ListFragment to implement lateral navigation with the ViewPager 
and all of a sudden the ListFragment stopped working. There is no exception 
thrown or anything. The list with all the items is simply not shown. Is the 
support.v4.ListFragment in any way working differently than the normal 
ListFragment or am I missing something else entirely?

Here is the code for the ListFragment:

<code>public class VisuTextFragment extends ListFragment {

    private Storage    mStorage;

    private int        mFilterSensortype;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mStorage = Storage.newSQLiteDatabase(getActivity());
        mFilterSensortype = -1;
        setHasOptionsMenu(true);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        return inflater.inflate(R.layout.l_visu_text, container, false);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        fillData();
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        inflater.inflate(R.menu.textvis, menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.menu_filter:
            final Dialog dialog = new Dialog(getActivity());
            dialog.setTitle("Filter by sensor type");
            dialog.setContentView(R.layout.l_dialog_filter);

            Button ok = (Button) dialog.findViewById(R.id.filter_ok);
            ok.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    int filter = Integer.parseInt(((EditText) 
dialog.findViewById(R.id.et_filter)).getText().toString());
                    mFilterSensortype = filter;
                    fillData();
                    dialog.dismiss();
                }
            });

            Button cancel = (Button) 
dialog.findViewById(R.id.filter_cancel);
            cancel.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    dialog.cancel();
                }
            });

            
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            dialog.show();
            break;
        }
        return true;
    }

    @Override
    public void onResume() {
        super.onResume();
        fillData();
    }

    public void fillData() {
        Log.d("VisuTextFragment", "fillData()");
        Cursor cursor;
        if (mFilterSensortype == -1)
            cursor = mStorage.queryAllAsCursor();
        else
            cursor = mStorage.query(mFilterSensortype);

        TextVisCursorAdapter adapter = new TextVisCursorAdapter(
                getActivity(),
                cursor,
                R.layout.l_visu_text_group,
                new String[] { Storage.ELEMENT_ID, 
Storage.ELEMENT_ENTRIES_DATE, Storage.ELEMENT_ENTRIES_LATITUDE, 
Storage.ELEMENT_ENTRIES_LONGITUDE, Storage.ELEMENT_ENTRIES_SENSORTYPE },
                new int[] { R.id.id, R.id.date, R.id.latitude, 
R.id.longitude, R.id.sensortype },
                R.layout.l_visu_text_child,
                new String[] { Storage.ELEMENT_MEASUREMENTS_VALUE },
                new int[] { R.id.value });

        ListView lv = (ListView) getListView();
        ExpandableListView elv = (ExpandableListView) lv;
        elv.setGroupIndicator(null);
        elv.setAdapter(adapter);
    }
}</code>

And this is the layout file:


<code><LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android";
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TextView
            android:gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/id"/>
        <TextView
            android:gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:text="@string/date"/>
        <TextView
            android:gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:text="@string/latitude"/>
        <TextView
            android:gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:text="@string/longitude"/>
        <TextView
            android:gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/sensortype"/>
    </LinearLayout>
    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    
        <ExpandableListView android:id="@+id/android:list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:transcriptMode="normal"/>
          <TextView android:id="@+id/android:empty"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/no_entries"/>
            
    </LinearLayout>
</LinearLayout></code>

Just FYI: All the TextView's before the ExpandableListView are shown just 
fine. It's only the ExpandableListView that is not being drawn.

Best regards,
Minh Bui


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to