Skip to content Skip to sidebar Skip to footer

Android Strange Behavior With Listview And Custom Cursor Adapter

I have a problem with a list view and a custom cursor adapter and I just can't seem to figure out what is wrong with my code. Basically, in my activity I call initalize() that does

Solution 1:

I figured out the problem and as I suspected it was a problem with my code. Setting the TextView's visibility to view.GONE or view.INVISIBLE works great. The problem was that I never made it visible again. I never called view.VISIBLE and that caused a whole bunch of problems.

 if (c.getColumnName(0).matches("section")){

    int nameCol = c.getColumnIndex("section");
    String section = c.getString(nameCol);

    TextView section_text = (TextView) v.findViewById(R.id.text1);
    if ((section.length() > 0)) {

        section_text.setText(section);
        // I forgot this!!!!!
        section_text.setVisibility(view.VISIBLE);

    }   else {
     //so we don't have an empty spot
        section_text.setVisibility(view.GONE);

    }

}

Post a Comment for "Android Strange Behavior With Listview And Custom Cursor Adapter"