Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think what you wanted to do is create an apparently infinite list of layouts being flinged by either the ViewFlipper or Christian's ViewFlinger. And also you want to keep reusing views / layouts inside the Flinger / Flipper. Right ?</p> <p>If yes, probably the following is what you wanted to do. I've done this based on Christian's ViewFlinger,</p> <p>Here you go,</p> <p>First add three layouts to the ViewFlinger:</p> <pre><code>&lt;com.egoclean.android.widget.flinger.ViewFlinger android:id="@+id/calendarViewFlipper" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;ScrollView android:id="@+id/calendarViewLayout0" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;/ScrollView&gt; &lt;ScrollView android:id="@+id/calendarViewLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;/ScrollView&gt; &lt;ScrollView android:id="@+id/calendarViewLayout2" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;/ScrollView&gt; &lt;/com.egoclean.android.widget.flinger.ViewFlinger&gt; </code></pre> <p>Then inside your activity, you take an array of three views so that you can access them directly through the array instead of searching every time inside the flinger, </p> <pre><code>private ViewFlinger viewFlinger; private ViewGroup layouts[] = new ViewGroup[3]; private boolean userEvent = false; @Override public final void onCreateSub(Bundle savedInstanceState) { setContentView(R.layout.your_layout); viewFlinger = (ViewFlinger) findViewById(R.id.calendarViewFlipper); layouts[0] = (ViewGroup) findViewById(R.id.calendarViewLayout0); layouts[1] = (ViewGroup) findViewById(R.id.calendarViewLayout1); layouts[2] = (ViewGroup) findViewById(R.id.calendarViewLayout2); viewFlinger.setOnScreenChangeListener(new ViewFlinger.OnScreenChangeListener() { @Override public void onScreenChanging(View newScreen, int newScreenIndex) { } @Override public void onScreenChanged(View newScreen, int newScreenIndex) { if (userEvent) { ViewGroup tempLayout = null; if (newScreenIndex != 1) { // We don't want our actions to raise events and create a cyclic event chain userEvent = false; if (newScreenIndex == 2) // Scrolling towards right { tempLayout = layouts[0]; viewFlinger.removeViewFromFront(); viewFlinger.addViewToBack(tempLayout); layouts[0] = layouts[1]; layouts[1] = layouts[2]; layouts[2] = tempLayout; // Any other logic comes here... } else if (newScreenIndex == 0) // Scrolling towards left { tempLayout = layouts[2]; viewFlinger.removeViewFromBack(); viewFlinger.addViewToFront(tempLayout); layouts[2] = layouts[1]; layouts[1] = layouts[0]; layouts[0] = tempLayout; // Any other logic comes here... } // We switch the screen index back to 1 since the current screen index would change back to 1 viewFlinger.setCurrentScreenNow(1, false); userEvent = true; // And any other logic that you'd like to put when the swapping is complete May be fill the swapped view with the correct values based on its new location etc... View result = refreshView(tempLayout.getChildAt(0)); if (result.getParent() != tempLayout) { ((ViewGroup) result.getParent()).removeView(result); tempLayout.removeAllViews(); tempLayout.addView(result); } } } } }); } </code></pre> <p>I hope this is clear to you and helps you with your problem. It is working very fine for me! Should work fine for you too.</p> <p>P.S. Thanks @ Christian for the ViewFlinger, it is awesome. However it lacks some good onConfigurationChanged logic, if you get time do put something in :). The rest is the best !</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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