Tuesday, 15 March 2011

android - In fllipperview childview which added is not working -



android - In fllipperview childview which added is not working -

i have used flipper.we add together layout in flipper tag. below

<flipper> <linearlayout1> <linearlayout2> </flipper>

in programme there 3 activity want show in flipper(which should flipp 1 after another.)

each activity perform task seperately.

when add together layout file flipper tag. below shown,

(this main xml file)

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" > <viewflipper android:id="@+id/viewflipper" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff" > <include android:id="@+id/screenxyzf" layout="@layout/screenxyz" /> <include android:id="@+id/screenabcf" layout="@layout/screenabc" /> <include android:id="@+id/activity_mainf" layout="@layout/activity_main" /> </viewflipper> </linearlayout>

// java code...

package com.example.exampledemo3; import android.app.activity; import android.os.bundle; import android.view.motionevent; import android.view.view; import android.widget.linearlayout; import android.widget.viewflipper; public class swipe extends activity { viewflipper flipper; float lastx; view.ontouchlistener gesturelistener; linearlayout chaptermain,chapterabc,chapterxyz; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.swipe); flipper = (viewflipper) findviewbyid(r.id.viewflipper); /*chaptermain=(linearlayout) findviewbyid(r.id.activity_mainf); chapterabc=(linearlayout) findviewbyid(r.id.screenabcf); chapterxyz=(linearlayout) findviewbyid(r.id.screenxyzf);*/ flipper.setdisplayedchild(r.id.activity_mainf); flipper.setdisplayedchild(r.id.screenabcf); flipper.setdisplayedchild(r.id.screenxyzf); } public boolean ontouchevent(motionevent touchevent) { switch (touchevent.getaction()) { case motionevent.action_down: { lastx = touchevent.getx(); break; } case motionevent.action_up: { float currentx = touchevent.getx(); if (lastx < currentx) { if (flipper.getdisplayedchild() == 0) break; flipper.setinanimation(this, r.anim.in_from_left); flipper.setoutanimation(this, r.anim.out_to_right); flipper.shownext(); } if (lastx > currentx) { if (flipper.getdisplayedchild() == 1) break; flipper.setinanimation(this, r.anim.in_from_right); flipper.setoutanimation(this, r.anim.out_to_left); flipper.showprevious(); } break; } } homecoming false; } }

now in code flipper working fine activities want show in flipper not working(activites not working,means listview not loading data,the button,textview visible dont back upwards event).

can tell me should do..?

have created "screenxyz.xml" , "screenabc.xml" files , filled contents ? you must set android:id each include or else useless. you can safety remove linearlayout if there no other view except viewflipper.

check out this:

<viewflipper xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/viewflipper" android:background="#ffffff" > <include layout="@layout/screenxyz" android:id="@+id/xyzview" /> <include layout="@layout/activity_main" android:id="@+id/mainview" /> <include layout="@layout/screenabc" android:id="@+id/abcview" /> </viewflipper>

android viewflipper

No comments:

Post a Comment