位置 0 に ViewFlipper を含む ListView がありますが、showNext または showPrevious を使用できません。効果はありません。
以下のコード スニペットは、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 を返します。
どんな助けでも大歓迎です... :)