android gallery 循环显示的时候报错,Reason: keyDispatchingTimedOut

宋建 发布于 2012/06/25 19:23
阅读 2K+
收藏 0

在对public int getCount()重写的时候,为了实现循环显示图片,将return ids.length;    改为Integer.MAX_VALUE;后,运行程序,程序会卡死,很长时间没反应,最后死亡。如果不实现循环就不会出现问题。有知道的请讲解一下,先谢谢了,代买如下:

@Override
 public int getCount()
 {
  return ids.length;       //Integer.MAX_VALUE;修改这个地方报错,
 }

 @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.image_item, null);
  }

  ImageView imageView = ((ImageView) convertView.findViewById(R.id.imgView));
  imageView.setImageResource(ids[position % ids.length]);
  return convertView;

 }
加载中
0
lwx
lwx
gallery.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view,
					int position, long id) {
				switcher.setImageResource(images[position%images.length]);//这里你也要同样设置成%
				
			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
				// TODO Auto-generated method stub
				
			}
			
		});
0
lwx
lwx
switcher.setImageResource(images[position%images.length]);
返回顶部
顶部