Note that there are some explanatory texts on larger screens.

plurals
  1. POMy View flipper is not working
    text
    copied!<p><strong>Hi I have created a view flipper in my activity and it is not working,while clicking the tab for the view flipper the application suddenly getting stopped,I have added the activity in manifest file but it is not working, I need a better solution, I am giving my logcat below</strong> </p> <pre><code>08-21 12:33:56.781: E/AndroidRuntime(28171): FATAL EXCEPTION: main 08-21 12:33:56.781: E/AndroidRuntime(28171): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.neochat/com.neochat.Viewflip}: android.view.InflateException: Binary XML file line #75: Error inflating class &lt;unknown&gt; 08-21 12:33:56.781: E/AndroidRuntime(28171): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 08-21 12:33:56.781: E/AndroidRuntime(28171): at android.app.ActivityThread.startActivityNow(ActivityThread.java:2023) 08-21 12:33:56.781: E/AndroidRuntime(28171): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135) </code></pre> <p><strong>here is the code for the view flip java</strong></p> <pre><code> public class Viewflip extends Activity { private ViewFlipper viewFlipper; private float lastX; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gallery); viewFlipper = (ViewFlipper) findViewById(R.id.view_flipper); } // Method to handle touch event like left to right swap and right to left swap 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 &lt; 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 &gt; 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; } } </code></pre> <p>giving my xml file for the view flip below..</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;ViewFlipper android:id="@+id/view_flipper" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="6dip" &gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:orientation="vertical" &gt; &lt;ImageView android:layout_marginTop="15dp" android:id="@+id/imageView1" android:layout_width="450dp" android:layout_height="450dp" android:src="@drawable/scene1" /&gt; &lt;/LinearLayout&gt; &lt;!-- Layout 2 for 2nd Screen --&gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:orientation="vertical" &gt; &lt;ImageView android:layout_marginTop="15dp" android:id="@+id/imageView1" android:layout_width="450dp" android:layout_height="450dp" android:src="@drawable/scene2" /&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:orientation="vertical" &gt; &lt;ImageView android:layout_marginTop="15dp" android:id="@+id/imageView1" android:layout_width="450dp" android:layout_height="450dp" android:src="@drawable/scene3" /&gt; &lt;/LinearLayout&gt; &lt;/ViewFlipper&gt; &lt;/LinearLayout&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload