tags:

views:

32

answers:

2

I have a few doubts about view flipper

I am using viewflipper to go to another view using scroll_left animation.

i have kept 2 linearlayouts inside the ViewFlipper

now i want 4 views....

like 1st view contains 3 btns.

1st btn click -> 2nd view scrolls in -> back pressed 1st view scrolls back 2nd btn click -> 3rd view scrolls in -> back pressed 1st view scrolls back 3rd btn click -> 4th view scrolls in -> back pressed 1st view scrolls back

so, how am i going to arrange 4 linearlayouts to work in flipNext ....

now ideally 2, 3, 4 views are in only second level of navigation. I want to draw a line, point or rectangle when 2, 3, 4 views come up, but they all are different shapes. So what would be the method to draw that ?

A: 

You can do it the following way:

<LinearLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/header">
<TextView
android:id="@+id/header_text"
android:gravity="center"
android:textSize="25px"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:layout_width="fill_parent"
    android:paddingBottom="5px">
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/flipper"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <include android:id="@+id/chatView"  layout="@layout/chat_view" />
    <include android:id="@+id/userView"  layout="@layout/user_view" />
    <include android:id="@+id/gameView" layout="@layout/game_view"/>
    <include android:id="@+id/allGamesView" layout="@layout/all_game_view" />
</ViewFlipper>

As you can see, i defined a TextView which is displayed every time. The ViewFlipper is below this header TextView. So you only flip this part of the whole view. To flip from view 1 to 2, you just call

flipper.showNext();

Do flip from 1 to 3, you just call:

flipper.showNext();
flipper.showNext();

And to flip from 4 to 2, you call:

flipper.showPrevious();
flipper.showPrevious();
Roflcoptr
A: 

wont that give the animation a little weird feeling, like it will be view 1 slided to view 2 then slided to view 3 ?

I want 1 slided to 2 back slided back to 1 1 slided to 3 back slided back to 1 1 slided to 4 slided back to 1

secondly, which function will be called if i want to do some custom drawing when view 2/3/4 is displayed ? all of them might have different drawings to do.

how would chart_view xml look like ?

mynameisanthpny