0
我有一個viewflipper,它的孩子是動態創建的,它們可以是textview或webview。當孩子是TextView時,視圖翻轉器正確地閃爍,但當孩子是webview時不會飛起來。Viewflipper在兒童視圖爲webview時不扔光
我有一個viewflipper,它的孩子是動態創建的,它們可以是textview或webview。當孩子是TextView時,視圖翻轉器正確地閃爍,但當孩子是webview時不會飛起來。Viewflipper在兒童視圖爲webview時不扔光
我遇到了同樣的問題。我面臨的問題是在一個視圖中,我在另一個視圖中有一個webview我在第一個視圖中有兩個imageviews我試圖交換視圖不會改變到第二個視圖我用觸摸事件在視圖之間進行更改,但這並未發生。後來我使用觸摸事件的webview也然後我能夠交換意見。
用於交換觸摸事件的代碼如下。
public boolean onTouchEvent(MotionEvent touchevent)
{
switch (touchevent.getAction())
{
// when user first touches the screen to swap
case MotionEvent.ACTION_DOWN:
{
lastX = touchevent.getX();
break;
}
case MotionEvent.ACTION_UP:
{
float currentX = touchevent.getX();
// if left to right swipe on screen
if (lastX < currentX)
{
// If no more View/Child to flip
if (viewFlipper.getDisplayedChild() == 0)
break;
// set the required Animation type to ViewFlipper
// The Next screen will come in form Left and current Screen will go OUT from Right
viewFlipper.setInAnimation(this, R.anim.in_from_left);
viewFlipper.setOutAnimation(this, R.anim.out_to_right);
// Show the next Screen
viewFlipper.showNext();
}
// if right to left swipe on screen
if (lastX > currentX)
{
if (viewFlipper.getDisplayedChild() == 1)
break;
// set the required Animation type to ViewFlipper
// The Next screen will come in form Right and current Screen will go OUT from Left
viewFlipper.setInAnimation(this, R.anim.in_from_right);
viewFlipper.setOutAnimation(this, R.anim.out_to_left);
// Show The Previous Screen
viewFlipper.showPrevious();
}
break;
}
}
return false;
}
使用相同的代碼爲您的WebView setOnTouchListener,因此,它可能爲你工作。
希望所以這可以幫助你。
感謝和問候, G.Shashank Reddy。
您的意見應該是相同的類型假設如果你直接在視圖中使用textview比所有應該是textview,如果你想使用不同的視圖比用於所有動態視圖一個父線性或任何其他佈局視圖爲每個添加視圖 – Khan