我已經使用Flipper.we通常在flipper標籤中添加布局。如下在fllipperview子視圖中添加不起作用
<flipper>
<LinearLayout1>
<LinearLayout2>
</flipper>
在我的計劃有三個活動,我想在鰭顯示(這應該flipp此起彼伏。)
每個活動seperately執行一些任務。
當我將該佈局文件添加到鰭標籤。如下圖所示,
(這是我的主XML文件)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<ViewFlipper
android:id="@+id/ViewFlipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff" >
<include
android:id="@+id/screenxyzf"
layout="@layout/screenxyz" />
<include
android:id="@+id/screenabcf"
layout="@layout/screenabc" />
<include
android:id="@+id/activity_mainf"
layout="@layout/activity_main" />
</ViewFlipper>
</LinearLayout>
//我的Java代碼...
package com.example.exampledemo3;
import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ViewFlipper;
public class Swipe extends Activity {
ViewFlipper flipper;
float lastX;
View.OnTouchListener gestureListener;
LinearLayout chapterMain,chapterAbc,chapterXyz;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.swipe);
flipper = (ViewFlipper) findViewById(R.id.ViewFlipper);
/*chapterMain=(LinearLayout) findViewById(R.id.activity_mainf);
chapterAbc=(LinearLayout) findViewById(R.id.screenabcf);
chapterXyz=(LinearLayout) findViewById(R.id.screenxyzf);*/
flipper.setDisplayedChild(R.id.activity_mainf);
flipper.setDisplayedChild(R.id.screenabcf);
flipper.setDisplayedChild(R.id.screenxyzf);
}
public boolean onTouchEvent(MotionEvent touchevent) {
switch (touchevent.getAction()) {
case MotionEvent.ACTION_DOWN: {
lastX = touchevent.getX();
break;
}
case MotionEvent.ACTION_UP: {
float currentX = touchevent.getX();
if (lastX < currentX) {
if (flipper.getDisplayedChild() == 0)
break;
flipper.setInAnimation(this, R.anim.in_from_left);
flipper.setOutAnimation(this, R.anim.out_to_right);
flipper.showNext();
}
if (lastX > currentX) {
if (flipper.getDisplayedChild() == 1)
break;
flipper.setInAnimation(this, R.anim.in_from_right);
flipper.setOutAnimation(this, R.anim.out_to_left);
flipper.showPrevious();
}
break;
}
}
return false;
}
}
現在在我的代碼腳蹼工作正常,但活動,我想在Flipper中顯示不工作(Activites不工作,意味着listview不加載數據,按鈕,textview可見但不支持任何事件)。
有誰能告訴我該怎麼辦..?
ü可以發佈您的代碼對包括標籤只是追加問題 – Pratik 2013-02-09 10:45:18
@Pratik:我添加的代碼。 screenxyz.xml,screenabc.xml和activity_main.xml是我的佈局文件。 – Jayshree 2013-02-09 11:14:36
@Guddu你是什麼意思下「不工作」,他們不顯示在屏幕上或什麼? – Evos 2013-02-09 11:31:17