viewflipper를 사용하여 여러보기간에 슬라이드하려고하는 Android 앱을 만들고 있습니다. 나는 here에서 도움을 청했습니다. 나는 코드를 실험 해 보았지만 지금은 문제가있다. viewflipper가보기간에 전환하지 않기 때문에 내 레이아웃 중 하나에서 scrollview가 있습니다. 아무도 나를 도울 수 있습니까?Viewflipper가 ScrollView와 함께 작동하지 않습니다.
이<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<ViewFlipper
android:id="@+id/details"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<!-- <ScrollView -->
<!-- android:id="@+id/flotest" -->
<!-- android:layout_width="match_parent" -->
<!-- android:layout_height="match_parent" -->
<!-- android:background="#FFFFFF" > -->
<!-- <LinearLayout -->
<!-- android:id="@+id/LR1" -->
<!-- android:layout_width="match_parent" -->
<!-- android:layout_height="match_parent" > -->
<TextView
android:id="@+id/floText"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/flo_garbage"
android:textColor="#000000" />
<!-- </LinearLayout> -->
<!-- </ScrollView> -->
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/rl1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/current_city"
android:textColor="#000000" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/disclosure" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<TextView
android:id="@+id/floText"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="FRIENDS PAGE"
android:textColor="#000000"
android:textSize="50dip" />
</LinearLayout>
</ViewFlipper>
</LinearLayout>
위의 코드는 완벽하게 잘 작동하지만 난이있는 ScrollView 부분의 주석을 해제하는 경우, 슬라이딩가 작동하지 않습니다이 통해 슬쩍 세 화면 내 XML 레이아웃 코드입니다. 내가 this 및 this 같이이 공통의 문제를 알고 있지만 내가 모든 솔루션을 찾을 수 없습니다
public class main extends Activity implements OnTouchListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
layMain = (LinearLayout) findViewById(R.id.layout_main);
layMain.setOnTouchListener((OnTouchListener) this);
}
public boolean onTouch(View arg0, MotionEvent arg1) {
// Get the action that was done on this touch event
switch (arg1.getAction()) {
case MotionEvent.ACTION_DOWN: {
// store the X value when the user's finger was pressed down
downXValue = arg1.getX();
break;
}
case MotionEvent.ACTION_UP: {
// Get the X value when the user released his/her finger
float currentX = arg1.getX();
// going backwards: pushing stuff to the right
if (downXValue < currentX) {
ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);
vf.setInAnimation(AnimationUtils.loadAnimation(this,
R.anim.push_left_in));
vf.setOutAnimation(AnimationUtils.loadAnimation(this,
R.anim.push_right_out));
if (screenmiddle) {
vf.showNext();
screenleft = true;
screenmiddle = false;
screenright = false;
} else if (screenright) {
vf.showNext();
screenleft = false;
screenmiddle = true;
screenright = false;
}
}
// going forwards: pushing stuff to the left
if (downXValue > currentX) {
ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);
vf.setInAnimation(AnimationUtils.loadAnimation(this,
R.anim.push_right_in));
vf.setOutAnimation(AnimationUtils.loadAnimation(this,
R.anim.push_left_out));
if (screenleft) {
vf.showPrevious();
screenleft = false;
screenmiddle = true;
screenright = false;
} else if (screenmiddle) {
vf.showPrevious();
screenleft = false;
screenmiddle = false;
screenright = true;
}
}
break;
}
}
// if you return false, these actions will not be recorded
return true;
}
}
: 이것은 내 활동 코드입니다.