0

Please help me with this guys, i am stuck up

I am Working on a viewpager, where i require my linearlayout change it's visibilty on a button click, but the visibilty property seems to but not working.

Here is my code

public class MyPagerAdapter extends PagerAdapter {

        @Override
        public Object instantiateItem(final View collection, final int position) {
            Log.d("Inside", "Pager");
            PagerView = new View(collection.getContext());
            LayoutInflater inflater = (LayoutInflater) collection.getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            PagerView = inflater.inflate(R.layout.bigimage, null);
            imgSubmenu = (ScalableImageView)PagerView.findViewById(R.id.imgSubMenu);
            btnBack = (Button)PagerView.findViewById(R.id.btnBack);
            btnCart = (Button) PagerView.findViewById(R.id.btnCart);
            btnCallWaiter = (Button) PagerView.findViewById(R.id.btnCallWaiter);
            btnPayBill = (Button) PagerView.findViewById(R.id.btnPayBill);
            btnReadMore = (Button) PagerView.findViewById(R.id.btnReadMore);
            btnAddtoOrder = (Button) PagerView.findViewById(R.id.btnAddtoOrder);
            tvSubMenuName = (TextView) PagerView.findViewById(R.id.tvSubMenuName);
            tvDescption = (TextView) PagerView.findViewById(R.id.tvDescrption);
            readLayout=(LinearLayout)PagerView.findViewById(R.id.readLayout);
            font = Typeface.createFromAsset(MenuSelectionActivity.this.getAssets(),
                    "fonts/BEBAS___.ttf");
            btnBack.setTypeface(font, Typeface.BOLD);
            btnCallWaiter.setTypeface(font, Typeface.BOLD);
            btnPayBill.setTypeface(font, Typeface.BOLD);
            btnReadMore.setTypeface(font, Typeface.BOLD);
            tvSubMenuName.setTypeface(font, Typeface.BOLD);
            btnReadMore.setTypeface(font, Typeface.BOLD);
            tvDescption.setTypeface(font, Typeface.BOLD);
            btnAddtoOrder.setTypeface(font, Typeface.BOLD);
            ((ViewPager) collection).addView(PagerView, 0);
            DisplayItem(position);
            btnReadMore.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    Log.d("readtype",""+readtype);
                    if(readtype==0)
                    {
                        readLayout.setVisibility(View.GONE);
                        btnReadMore.setText("READ MORE");
                        btnReadMore.setBackgroundResource(drawable.readmore);
                        readtype=1;

                    }
                    else
                    {
                        readLayout.setVisibility(View.VISIBLE);
                        btnReadMore.setText("READ LESS");
                        btnReadMore.setBackgroundResource(drawable.readless);                   
                        readtype=0;
                    }
                }
            });
            btnBack.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    finish();
                }
            });
            return PagerView;
        }

        @Override
        public void destroyItem(final View arg0, final int arg1,
                final Object arg2) {
            ((ViewPager) arg0).removeView((View) arg2);

        }

        @Override
        public boolean isViewFromObject(final View arg0, final Object arg1) {
            return arg0 == ((View) arg1);

        }

        @Override
        public void finishUpdate(View arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void restoreState(Parcelable arg0, ClassLoader arg1) {
            // TODO Auto-generated method stub

        }

        @Override
        public Parcelable saveState() {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public void startUpdate(View arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return SubMenuIdList.size();
        }

    } 

Can anyone please help me up.

hemant
  • 564
  • 2
  • 13
  • 37

1 Answers1

0

i think your code is right. have you tried to set the visibility with int?

setVisibility(0) -> visible  or setVisibility(View.VISIBLE)
setVisibility(4) -> invisible or setVisibility(View.INVISIBLE)
setVisibility(8) -> gone or setVisibility(View.GONE)
Booger
  • 18,579
  • 7
  • 55
  • 72
D Ferra
  • 1,223
  • 3
  • 12
  • 21