Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Two different Layout throw error #130

Open
atulsethi opened this issue Feb 25, 2015 · 4 comments
Open

Two different Layout throw error #130

atulsethi opened this issue Feb 25, 2015 · 4 comments

Comments

@atulsethi
Copy link

FlipViewController flipView;
flipView = new FlipViewController(getActivity());

    flipView.setAdapter(new BaseAdapter() {
        @Override
        public int getCount() {
            return 10;
        }

        @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) {

        LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

            switch (position)
            {
                case 0:


                    if (convertView == null) {
                        // Inflate the layout with image
                        convertView = (RelativeLayout) inflater.inflate(R.layout.fragmenttab1, parent, false);
                        ((TextView) convertView.findViewById(R.id.Text_Fragment1)).setText("Fragment_1 : "+position);

                        return convertView;
                    }else {
                        ((TextView) convertView.findViewById(R.id.Text_Fragment1)).setText("Fragment_1 : "+position);
                        return convertView;

                    }


                default:

                    if (convertView == null) {
                        // Inflate the layout with image
                        convertView = (RelativeLayout) inflater.inflate(R.layout.fragmenttab2, parent, false);
                        ((TextView) convertView.findViewById(R.id.Text_Fragment2)).setText("Fragment_2 : "+position);

                        return convertView;
                    }else {
                        ((TextView) convertView.findViewById(R.id.Text_Fragment2)).setText("Fragment_2 : "+position);
                        return convertView;

                    }


            }



        }
    });


    return flipView;
@VAdaihiep
Copy link

You should use getItemViewType() instead of switch(position)
More detail here: http://android.amberfog.com/?p=296 (part Different list items’ layouts)

@atulsethi
Copy link
Author

Thanks Vadaihiep , I have solved the problem by issue 51 which you provided in Demo

@atulsethi
Copy link
Author

Vadaihiep , how can implement pull to refresh with FlipViewController ?

@VAdaihiep
Copy link

You can try to use Android SwipeRefreshLayout: https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants