0

Consider folowing code:

public class MediaItemAdapter extends BaseAdapter {
    final List<Row> rows;
    public MediaItemAdapter(Activity activity, ArrayList<HashMap<String, String>> data) {
        Log.d("mediaadapter", "listcreation: " + data.size());
        rows = new ArrayList<Row>();// member variable
        int i=0;
        for (HashMap<String, String> addvert:data) {

            rows.add(new MeadiaRow((LayoutInflater) activity
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE), addvert));
            Log.d("mediaadapter", addvert.get("title"));
            if (i % 20 == 0) {
                rows.add(new SourseRow((LayoutInflater) activity
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE)));
            }
            i++;
        }
    }

It is constructor of my adapter. After each 20 MediaRows, I wish to add one sourse row. It has ArrayList data. The problem that data is always empty. I build my adapter according to this tutorial. In a tutorial thingth works fine. But in tutorial initial dataset is predefined. In my cade initial data set is empty and populates in working time. However, after I call notifyDataSetChanged the data remains empty (even though the dataset is not).
How can I get updated values for data?

Yarh
  • 4,459
  • 5
  • 45
  • 95

1 Answers1

0

What is nesessary to do - is to move

int i=0;
        for (HashMap<String, String> addvert:data) {

            rows.add(new MeadiaRow((LayoutInflater) activity
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE), addvert));
            Log.d("mediaadapter", addvert.get("title"));
            if (i % 20 == 0) {
                rows.add(new SourseRow((LayoutInflater) activity
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE)));
            }
            i++;
        }

from adapter to overriden notifyDataSetChanged in adapter class

Yarh
  • 4,459
  • 5
  • 45
  • 95