2012-06-23 15 views
0

我有一个viewflipper,它的孩子是动态创建的,它们可以是textview或webview。当孩子是TextView时,视图翻转器正确地闪烁,但当孩子是webview时不会飞起来。Viewflipper在儿童视图为webview时不扔光

+0

您的意见应该是相同的类型假设如果你直接在视图中使用textview比所有应该是textview,如果你想使用不同的视图比用于所有动态视图一个父线性或任何其他布局视图为每个添加视图 – Khan

回答

0

我遇到了同样的问题。我面临的问题是在一个视图中,我在另一个视图中有一个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。