我在视图组中遇到错误

Posted

技术标签:

【中文标题】我在视图组中遇到错误【英文标题】:I'm getting error in view group 【发布时间】:2013-07-07 11:24:55 【问题描述】:
 public void onCreate(Bundle paramBundle)
  
      super.onCreate(paramBundle);
      Bundle localBundle = getIntent().getExtras();
      setContentView(pager);
        String[] arrayOfString = localBundle.getStringArray("com.example.image.IMAGES");
        int i = localBundle.getInt("com.example.image.IMAGE_POSITION", 0);
        if (paramBundle != null)
          i = paramBundle.getInt("STATE_POSITION");
        this.options = new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.ic_launcher).showImageOnFail(R.drawable.ic_launcher).resetViewBeforeLoading(true).cacheOnDisc(true).imageScaleType(ImageScaleType.NONE).bitmapConfig(Bitmap.Config.RGB_565).displayer(new FadeInBitmapDisplayer(300)).build();
        this.pager = ((ViewPager)findViewById(R.id.myfivepanelpager));
      this.pager.setAdapter(new ImagePagerAdapter(arrayOfString));
        this.pager.setCurrentItem(i);
  
  public void onSaveInstanceState(Bundle paramBundle)
  
    paramBundle.putInt("STATE_POSITION", this.pager.getCurrentItem());
  

   private class ImagePagerAdapter extends PagerAdapter
  
        private String[] images;
        private LayoutInflater inflater;

        ImagePagerAdapter(String[] arg2)
        
             Object localObject = null;
             this.images = (String[]) localObject;
             this.inflater = ImagePagerActivity.this.getLayoutInflater();;
        

        public void destroyItem(View paramView, int paramInt, Object paramObject)
        
          ((ViewPager)paramView).removeView((View)paramObject);
        

        public void finishUpdate(View paramView)
        
        

        public int getCount()
        
          return this.images.length;
        

        public Object instantiateItem(View paramView, int paramInt)
        
          FrameLayout localView = (FrameLayout)this.inflater.inflate(R.layout.item_pager, null);
          ImageView localImageView = (ImageView)localView.findViewById(R.id.imageView1);
          final ProgressBar localProgressBar = (ProgressBar)localView.findViewById(R.id.progressBar1);
          ImagePagerActivity.this.imageLoader.displayImage(this.images[paramInt], localImageView, ImagePagerActivity.this.options, new SimpleImageLoadingListener()
          
            public void onLoadingComplete(String paramAnonymousString, View paramAnonymousView, Bitmap paramAnonymousBitmap)
            
              localProgressBar.setVisibility(8);
            



            public void onLoadingStarted(String paramAnonymousString, View paramAnonymousView)
            
              localProgressBar.setVisibility(0);
            
          );
          ((ViewPager)paramView).addView(localView, 0);
          return localView;
        

        public boolean isViewFromObject(View paramView, Object paramObject)
        
          return paramView.equals(paramObject);
        

        public void restoreState(Parcelable paramParcelable, ClassLoader paramClassLoader)
        
        

        public Parcelable saveState()
        
          return null;
        

        public void startUpdate(View paramView)
               
    

【问题讨论】:

【参考方案1】:

改变

   setContentView(pager);

带有包含R.id.myfinepanepager的布局的id

setContentView(R.layout.nameoflayout);

【讨论】:

清理你的项目并重建它..然后再次运行

以上是关于我在视图组中遇到错误的主要内容,如果未能解决你的问题,请参考以下文章

选择项目时出现水平集合视图错误

关闭视图时发生自动布局内部错误

从 xib 加载视图控制器返回错误的帧

从 RDD 中的元组中解包项目时出现 Spark 错误

Xcode 中的错误“未设置视图出口。”

错误:所有观察都在同一组中,同时从闪亮的 ui 列表中动态过滤 R 模型