1
我有一個ListView,它包含位置0處的ViewFlipper。但我無法使用showNext或showPrevious它沒有任何作用。ViewFlipper的getDisplayedChild()方法總是返回0
下面的代碼片段展示了我是多麼實例viewFlipper
View view1 = inflater.inflate(R.layout.flipper, null);
viewFlipper=(ViewFlipper)view1.findViewById(R.id.flipper);
viewFlipper.addView(getChildView(v1,0),0);
viewFlipper.addView(getChildView(v2,1),1);
viewFlipper.addView(getChildView(v3,2),2);
viewFlipper.addView(getChildView(v4,3),3);
viewFlipper.addView(getChildView(v5,4),4);
viewFlipper.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(final View view, final MotionEvent event) {
gdt.onTouchEvent(event);
return true;
}
});
這是觀點的鰭狀肢的方法getChildView
private View getChildView(View view,int index){
LayoutInflater inflater = this.getLayoutInflater();
view = inflater.inflate(R.layout.event_feed, null);
//Event Highlight
highlight=(LinearLayout)view.findViewById(R.id.highlight);
media_url_value=(ImageView)view.findViewById(R.id.slider_pic);
slider_pic1=(ImageView)view.findViewById(R.id.slider_i1);
slider_pic2=(ImageView)view.findViewById(R.id.slider_i2);
slider_pic3=(ImageView)view.findViewById(R.id.slider_i3);
slider_pic4=(ImageView)view.findViewById(R.id.slider_i4);
slider_pic5=(ImageView)view.findViewById(R.id.slider_i5);
title_value=(TextView)view.findViewById(R.id.slider_title);
info_value=(TextView)view.findViewById(R.id.slider_info);
event_date_value=(TextView)view.findViewById(R.id.slider_eventdate);
imageLoader.DisplayImage(media_url[index],EventList.this,media_url_value);
title_value.setText(title[index]);
if(info[index].length()>=120)
info_value.setText(info[index].substring(0,120)+"......");
else
info_value.setText(info[index]);
event_date_value.setText(event_date[index]);
if(index==0){
slider_pic1.setBackgroundResource(R.drawable.slider_hover);
slider_pic2.setBackgroundResource(R.drawable.slider_empty);
slider_pic3.setBackgroundResource(R.drawable.slider_empty);
slider_pic4.setBackgroundResource(R.drawable.slider_empty);
slider_pic5.setBackgroundResource(R.drawable.slider_empty);
}
if(index==1){
slider_pic1.setBackgroundResource(R.drawable.slider_empty);
slider_pic2.setBackgroundResource(R.drawable.slider_hover);
slider_pic3.setBackgroundResource(R.drawable.slider_empty);
slider_pic4.setBackgroundResource(R.drawable.slider_empty);
slider_pic5.setBackgroundResource(R.drawable.slider_empty);
}
if(index==2){
slider_pic1.setBackgroundResource(R.drawable.slider_empty);
slider_pic2.setBackgroundResource(R.drawable.slider_empty);
slider_pic3.setBackgroundResource(R.drawable.slider_hover);
slider_pic4.setBackgroundResource(R.drawable.slider_empty);
slider_pic5.setBackgroundResource(R.drawable.slider_empty);
}
if(index==3){
slider_pic1.setBackgroundResource(R.drawable.slider_empty);
slider_pic2.setBackgroundResource(R.drawable.slider_empty);
slider_pic3.setBackgroundResource(R.drawable.slider_empty);
slider_pic4.setBackgroundResource(R.drawable.slider_hover);
slider_pic5.setBackgroundResource(R.drawable.slider_empty);
}
if(index==4){
slider_pic1.setBackgroundResource(R.drawable.slider_empty);
slider_pic2.setBackgroundResource(R.drawable.slider_empty);
slider_pic3.setBackgroundResource(R.drawable.slider_empty);
slider_pic4.setBackgroundResource(R.drawable.slider_empty);
slider_pic5.setBackgroundResource(R.drawable.slider_hover);
}
return view;
}
getDisplayedChild()總是返回0,雖然它是視圖之間翻轉。
任何幫助將不勝感激... :)
是的我已經嘗試了所有可能的東西,如清潔項目,檢查logcat的詳細信息。從近2天無法找到任何解決方案在谷歌或stackoverflow.Thanks您的回覆 –
任何人都可以幫助我找到解決方案。 –