1

I am using ViewFlow library from Github. ViewFlow

I am displaying four swipe screens using this library. In of these screens there is a listview. Data for this list changes when user presses a button. My problem is that i have to scroll the list or touch several times and then only the list is updated. Is there anything else that has to be done because I am using Viewflow ?

My mainactivity's relevant code is below :

    setContentView(R.layout.slidingpan);
    ViewFlow viewFlow = (ViewFlow) findViewById(R.id.viewflow);

    viewFlow.setAdapter(new screenAdapter(this));
    CircleFlowIndicator indic = (CircleFlowIndicator) findViewById(R.id.viewflowindic);
    viewFlow.setFlowIndicator(indic);

ScreenAdapter code is as follows:

public class screenAdapter extends BaseAdapter {

private LayoutInflater mInflater;
public static Context here;


private static final int[] ids = { R.layout.multiple_screen_1, 
  R.layout.layout_vol_opportunity, R.layout.multiple_screen_3,
                                R.layout.multiple_screen_4};

public screenAdapter(Context context) 
{
    this.here = context;
    mInflater = (LayoutInflater) 
    context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

@Override
public int getCount() {
    return ids.length;
}

@Override
public Object getItem(int position) {
    return position;
}

@Override
public long getItemId(int position) {
    return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.activity_main_page, null);
    }
    convertView = mInflater.inflate(ids[position], null);

    switch(ids[position])
    {
        case R.layout.multiple_screen_1:
            break;

        case R.layout.tabs_layout:      //volunteering opportunities

            break;

        case R.layout.multiple_screen_3:

            break;

        case R.layout.multiple_screen_4:
            break;
    }
    return convertView;
}
}

Following snippet shows how i am updating the list:

        projects.clear();

        boolean exit ;
        for (int i = 0 ; i < tempList.length; i++)
        {
            exit = false;
            ArrayList<Category> temp = filterList.get(i);   
            for(int j=0;j < temp.size();j++)    
            {
                for(int k = 0; k < filter.size();k++)   
                {
                    if(filter.get(k).equals(temp.get(j)))       
                    {
                        projects.add(tempList[i]);
                        exit = true;
                        break;
                    }
                }
                if(exit==true)
                    break;
            }
        }

        handle.post(new Runnable() {
            @Override
            public void run() {
                expListAdapter.notifyDataSetChanged();
            }
        });

The same problem was coming with expandiblelistview as well. It was not expanding unless i scroll it a little bit.

Anand
  • 1,335
  • 1
  • 12
  • 20

0 Answers0