2013-10-25 2 views
0
появляется

Пожалуйста, помогите мне с этим, ребята, я застрялView в Visibity становится установлен GONE, но все же Посмотреть на экране внутри PagerAdapter

Я работаю на ViewPager, где я требую мое изменение LinearLayout это visibilty при нажатии кнопки, но свойство visibilty похоже, но не работает.

Вот мой код

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(); 
     } 

    } 

Может кто-нибудь, пожалуйста, помогите мне.

+0

Я попытался удалить мою страницу. Адаптер, и он отлично работает. Это проблема внутри моего ViewPager – hemant

+0

Работает ли btnReadMore.setText правильно? Что дает Log.d ("readtype", "" + readtype)? – 2Dee

+0

-2Dee readtype - это мое условие для настройки видимости и его работы, но но видимая собственность не работает – hemant

ответ

0

Я думаю, что ваш код прав. Вы пытались установить видимость с помощью int?

setVisibility(0) -> visible or setVisibility(View.VISIBLE) 
setVisibility(4) -> invisible or setVisibility(View.INVISIBLE) 
setVisibility(8) -> gone or setVisibility(View.GONE) 
+0

-D Ferra Нет, он не работает с целыми значениями также – hemant

+0

-D Ferra Что-нибудь еще, что могло бы мне помочь, для установки этого свойства видимости? – hemant

+0

не знаю. есть только два метода. Возможно, ваша проблема в другой части –

Смежные вопросы