Search Results

Search found 33 results on 2 pages for 'viewflipper'.

Page 1/2 | 1 2  | Next Page >

  • android: How to set a listener that fires when my ViewFlipper shows a new child

    - by Joseph Cheek
    Hi Android gurus, I have a ViewFlipper for which I want a listener to fire when the child displayed is changed. I have set an OnFocusChangeListener to the ViewFlipper but it never fires when I flip from child 0 to child 1 or vice-versa. The ViewFlipper contains two RelativeLayouts and I have tried setting OnFocusChangeListeners for those but I get a ClassCastException when I try to set it. Here's my code: RelativeLayout songsLayout = (RelativeLayout) findViewById(R.id.song_page_layout); songsLayout.setOnFocusChangeListener(new OnFocusChangeListener() { public void onFocusChange(View view, boolean hasFocus) { showPopUp("View " + view.getId() + " now has focus: " + hasFocus); } } ); R.is.song_page_layout is one of my RelativeLayouts and showPopUp() is a function I use to show, well, popups. Does anyone have working code for some sort of trigger that fires when a ViewFlipper changes which child is displayed?

    Read the article

  • Best practice for viewflipper containing 10 linearlayouts?

    - by Brad Hein
    I'm embarking on a GUI Activity composed of a viewflipper, which I would like to contain 10 linearlayout layouts. Is it advisable to put all of my layouts into the same XML resource/layout file? If not, is there a more organized approach to coding a viewflipper with many layouts? Will having everything in the same file come at a significant performance cost?

    Read the article

  • parseInt and viewflipper layout problems

    - by user1234167
    I have a problem with parseInt it throws the error: unable to parse 'null' as integer. My view flipper is also not working. Hopefully this is an easy enough question. Here is my activity: import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.ViewFlipper; import xml.parser.dataset; public class XmlParserActivity extends Activity implements OnClickListener { private final String MY_DEBUG_TAG = "WeatherForcaster"; // private dataset myDataSet; private LinearLayout layout; private int temp= 0; /** Called when the activity is first created. */ //the ViewSwitcher private Button btn; private ViewFlipper flip; // private TextView tv; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); layout=(LinearLayout)findViewById(R.id.linearlayout1); btn=(Button)findViewById(R.id.btn); btn.setOnClickListener(this); flip=(ViewFlipper)findViewById(R.id.flip); //when a view is displayed flip.setInAnimation(this,android.R.anim.fade_in); //when a view disappears flip.setOutAnimation(this, android.R.anim.fade_out); // String postcode = null; // public String getPostcode { // return postcode; // } //URL newUrl = c; // myweather.setText(c.toString()); /* Create a new TextView to display the parsingresult later. */ TextView tv = new TextView(this); // run(0); //WeatherApplicationActivity postcode = new WeatherApplicationActivity(); try { /* Create a URL we want to load some xml-data from. */ URL url = new URL("http://new.myweather2.com/developer/forecast.ashx?uac=gcV3ynNdoV&output=xml&query=G41"); //String url = new String("http://new.myweather2.com/developer/forecast.ashx?uac=gcV3ynNdoV&output=xml&query="+WeatherApplicationActivity.postcode ); //URL url = new URL(url); //url.toString( ); //myString(url.toString() + WeatherApplicationActivity.getString(postcode)); // url + WeatherApplicationActivity.getString(postcode); /* Get a SAXParser from the SAXPArserFactory. */ SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); /* Get the XMLReader of the SAXParser we created. */ XMLReader xr = sp.getXMLReader(); /* Create a new ContentHandler and apply it to the XML-Reader*/ handler myHandler = new handler(); xr.setContentHandler(myHandler); /* Parse the xml-data from our URL. */ xr.parse(new InputSource(url.openStream())); /* Parsing has finished. */ /* Our ExampleHandler now provides the parsed data to us. */ dataset parsedDataSet = myHandler.getParsedData(); /* Set the result to be displayed in our GUI. */ tv.setText(parsedDataSet.toString()); } catch (Exception e) { /* Display any Error to the GUI. */ tv.setText("Error: " + e.getMessage()); Log.e(MY_DEBUG_TAG, "WeatherQueryError", e); } temp = Integer.parseInt(xml.parser.dataset.getTemp()); if(temp <0){ //layout.setBackgroundColor(Color.BLUE); //layout.setBackgroundColor(getResources().getColor(R.color.silver)); findViewById(R.id.flip).setBackgroundColor(Color.BLUE); } else if(temp > 0 && temp < 9) { //layout.setBackgroundColor(Color.GREEN); //layout.setBackgroundColor(getResources().getColor(R.color.silver)); findViewById(R.id.flip).setBackgroundColor(Color.GREEN); } else { //layout.setBackgroundColor(Color.YELLOW); //layout.setBackgroundColor(getResources().getColor(R.color.silver)); findViewById(R.id.flip).setBackgroundColor(Color.YELLOW); } /* Display the TextView. */ this.setContentView(tv); } @Override public void onClick(View arg0) { // TODO Auto-generated method stub onClick(View arg0) { // TODO Auto-generated method stub flip.showNext(); //specify flipping interval //flip.setFlipInterval(1000); //flip.startFlipping(); } } this is my dataset: package xml.parser; public class dataset { static String temp = null; // private int extractedInt = 0; public static String getTemp() { return temp; } public void setTemp(String temp) { this.temp = temp; } this is my handler: public void characters(char ch[], int start, int length) { if(this.in_temp){ String setTemp = new String(ch, start, length); // myParsedDataSet.setTempUnit(new String(ch, start, length)); // myParsedDataSet.setTemp; } the dataset and handler i only pasted the code that involves the temp as i no they r working when i take out the if statement. However even then my viewflipper wont work. This is my main xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/linearlayout1" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="25dip" android:text="Flip Example" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="25dip" android:id="@+id/tv" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="25dip" android:text="Flip" android:id="@+id/btn" android:onClick="ClickHandler" /> <ViewFlipper android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/flip"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="25dip" android:text="Item1a" /> </LinearLayout> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="25dip" android:id="@+id/tv2" /> </ViewFlipper> </LinearLayout> this is my logcat: 04-01 18:02:24.744: E/AndroidRuntime(7331): FATAL EXCEPTION: main 04-01 18:02:24.744: E/AndroidRuntime(7331): java.lang.RuntimeException: Unable to start activity ComponentInfo{xml.parser/xml.parser.XmlParserActivity}: java.lang.NumberFormatException: unable to parse 'null' as integer 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1830) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread.access$1500(ActivityThread.java:132) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.os.Handler.dispatchMessage(Handler.java:99) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.os.Looper.loop(Looper.java:150) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread.main(ActivityThread.java:4293) 04-01 18:02:24.744: E/AndroidRuntime(7331): at java.lang.reflect.Method.invokeNative(Native Method) 04-01 18:02:24.744: E/AndroidRuntime(7331): at java.lang.reflect.Method.invoke(Method.java:507) 04-01 18:02:24.744: E/AndroidRuntime(7331): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849) 04-01 18:02:24.744: E/AndroidRuntime(7331): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607) 04-01 18:02:24.744: E/AndroidRuntime(7331): at dalvik.system.NativeStart.main(Native Method) 04-01 18:02:24.744: E/AndroidRuntime(7331): Caused by: java.lang.NumberFormatException: unable to parse 'null' as integer 04-01 18:02:24.744: E/AndroidRuntime(7331): at java.lang.Integer.parseInt(Integer.java:356) 04-01 18:02:24.744: E/AndroidRuntime(7331): at java.lang.Integer.parseInt(Integer.java:332) 04-01 18:02:24.744: E/AndroidRuntime(7331): at xml.parser.XmlParserActivity.onCreate(XmlParserActivity.java:118) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1794) I hope I have given enough information about my problems. I will be extremely grateful if anyone can help me out.

    Read the article

  • How to programmatically add view in ViewFlipper

    - by barmaleikin
    Hi, I have following main layout: <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"> <ViewFlipper android:id="@+id/viewstack" android:layout_width="fill_parent" android:layout_height="fill_parent"> <!-- Here I want to add my views which are located in separated xml files. --> </ViewFlipper> </LinearLayout> Here is example of my view: view_url.xml view_text.xml <EditText android:text="@+id/EditText01" android:id="@+id/EditText01" android:layout_height="wrap_content" android:contentDescription="Enter your text here" android:layout_width="fill_parent" android:height="200dp"/> I am trying to add views: viewstack = (ViewFlipper) findViewById(R.id.viewstack);)); View viewText = (View) findViewById(R.layout.view_text); viewstack.addView(viewText); < -- Emulator is crashing at this line View viewUrl = (View) findViewById(R.layout.view_url); viewstack.addView(viewUrl); I dont have any idea what is wrong with my code. I decided to put all my views in one file, but I still want to know how to fix my initial code.

    Read the article

  • Android ViewFlipper + homescreen animation

    - by Tim
    I am trying to use a ViewFlipper and make it act like the home screen(The layout will move with your finger). Check out this for an example. I want to do this with a ViewFlipper that only contains two children so the opposite view should be shown on either side of the current view depending on which way the user moves their finger. This code works but only for 1 direction at a time. This is in onTouchEvent. case MotionEvent.ACTION_MOVE: leftView.setVisibility(View.VISIBLE); rightView.setVisibility(View.VISIBLE); // move the current view to the left or right. currentView.layout((int) (touchEvent.getX() - oldTouchValue), currentView.getTop(), (int) (touchEvent.getX() - oldTouchValue) + 320, currentView.getBottom()); // place this view just left of the currentView leftView.layout(currentView.getLeft() - 320, leftView.getTop(), currentView.getLeft(), leftView.getBottom()); // place this view just right of the currentView rightView.layout(currentView.getRight(), rightView.getTop(), currentView.getRight() + 320, rightView.getBottom()); Which ever of the bottom two lines I put last that direction will work correctly but the other will not. Here is how I set the leftView and rightView: final View currentView = myFlipper.getCurrentView(); final View leftView, rightView; if (currentView == meView) { Log.d("current layout: ", "me"); leftView = youView; rightView = youView; } else if (currentView == youView) { Log.d("current layout: ", "you"); leftView = meView; rightView = meView; }else { leftView = null; rightView = null; } Is it going to be possible to set it up so that the same view is shown on both sides of the current view?

    Read the article

  • Android ViewFlipper is out of control

    - by Doug Miller
    I have an app that uses a ViewFlipper to display some text and images. I have the flipper's flipinterval set to 10 seconds, but also want to allow the user to click a button that will advance the flipper. The code blow works great on 2.2, the view is changed every 10 seconds and if I click flip_button the view is changed and the auto flip steps back in 10 seconds later. The 1.5 and 1.6 versions will remember the manual advance and it will happen every time in the rotation. What am I missing? private void initFlipButton(){ final ImageView flip_button = (ImageView) findViewById(R.id.flip_button); info_button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { flipper.stopFlipping(); flipper.showNext(); flipper.startFlipping(); } }); } private void initFlipper(){ flipper = (ViewFlipper) findViewById(R.id.flip_dog); flipper.setFlipInterval(10000); flipper.setInAnimation(inFromRightAnimation()); flipper.setOutAnimation(outToLeftAnimation()); flipper.startFlipping(); }

    Read the article

  • Making a ViewFlipper like the Home Screen using MotionEvent.ACTION_MOVE

    - by DJTripleThreat
    Ok I have a ViewFlipper with three LinearLayouts nested inside it. It defaults to showing the first one. This code: // Assumptions in my Activity class: // oldTouchValue is a float // vf is my view flipper @Override public boolean onTouchEvent(MotionEvent touchEvent) { switch (touchEvent.getAction()) { case MotionEvent.ACTION_DOWN: { oldTouchValue = touchEvent.getX(); break; } case MotionEvent.ACTION_UP: { float currentX = touchEvent.getX(); if (oldTouchValue < currentX) { vf.setInAnimation(AnimationHelper.inFromLeftAnimation()); vf.setOutAnimation(AnimationHelper.outToRightAnimation()); vf.showNext(); } if (oldTouchValue > currentX) { vf.setInAnimation(AnimationHelper.inFromRightAnimation()); vf.setOutAnimation(AnimationHelper.outToLeftAnimation()); vf.showPrevious(); } break; } case MotionEvent.ACTION_MOVE: { // TODO: Some code to make the ViewFlipper // act like the home screen. break; } } return false; } public static class AnimationHelper { public static Animation inFromRightAnimation() { Animation inFromRight = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); inFromRight.setDuration(350); inFromRight.setInterpolator(new AccelerateInterpolator()); return inFromRight; } public static Animation outToLeftAnimation() { Animation outtoLeft = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); outtoLeft.setDuration(350); outtoLeft.setInterpolator(new AccelerateInterpolator()); return outtoLeft; } // for the next movement public static Animation inFromLeftAnimation() { Animation inFromLeft = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); inFromLeft.setDuration(350); inFromLeft.setInterpolator(new AccelerateInterpolator()); return inFromLeft; } public static Animation outToRightAnimation() { Animation outtoRight = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); outtoRight.setDuration(350); outtoRight.setInterpolator(new AccelerateInterpolator()); return outtoRight; } } ... handles the view flipping but the animations are very "on/off". I'm wondering if someone can help me out with the last part. Assuming that I can access the LinearLayouts, is there a way where I can set the position of the layouts based on deltaX and deltaY? Someone gave me this link: https://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/view/animation/TranslateAnimation.java;h=d2ff754ac327dda0fe35e610752abb78904fbb66;hb=HEAD and said I should refer to the applyTransformation method for hints on how to do this but I don't know how to repeat this same behavior.

    Read the article

  • Android ViewFlipper + Gesture Detector

    - by Tim
    I am using gesture detector to catch "flings" and using a view flipper to change the screen when this happens. Some of my child views contain list views. The the gesture detector wont recognize a swipe if you swipe on the list view. But it will recognize it if it is onTop of TextView's or ImageView's. Is there a way to implement it so that it will recognize the swipes even if they are on top of another view that has a ClickListener?

    Read the article

  • How is the Viewflipper handling the back button in Android?

    - by Janusz
    I'm thinking about using a ViewFlipper for an Wizard like Activity. But I see one problem with this approach. The back button. Will the back button go back to the last shown activity or will the the Viewflipper somehow catch the back button event and only change to the last shown activity? I suspect the ViewFlipper to be treated as one Activity on the BackStack so is seems that is the wrong aproach for a wizard. Is this correct?

    Read the article

  • How to use a ListView and a ViewFlipper to navigate user in an Android app?

    - by virsir
    I want to set up some menu-like navigator for my app. There is a listView in the main page and it contains two items, click each one will show its child view with ViewFlipper, and if user clicked the back button, he will return to the homepage again. The question is how to make it, I can only use ViewFlipper to flip to next screen or prev screen, how to manage these child views here? How to put them in my layout xml file?

    Read the article

  • Listview Swipe inside viewflipper

    - by Faisal Abid
    Im trying to swipe left and right on a listview and get the viewflipper to swtich. Just like the remeberthemilk app and the default news and weather app on the nexus one (Swiping through news topics). Using various tutorials ive found , i came across on one stackoverflow that shows how to implement a swipe gesture class MyGestureDetector extends SimpleOnGestureListener { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) return true; // right to left swipe if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { viewFlipper.setInAnimation(slideRightIn); viewFlipper.setOutAnimation(slideRightOut); viewFlipper.showPrevious(); } } catch (Exception e) { // nothing } return true; } } And i got this working by doing lstView.setOnTouchListener(gestureListener); However sometimes what would happen is the listview setOnItemClickListener would be fired when the person is swiping. How do i prevent this from happening, and only get the setOnItemClickListener fired when the user actually clicks on it list item and not just swiping on it. Thanks, Faisal Abid

    Read the article

  • Android customizing ViewFlipper...

    - by wearysamurai
    So I'm having pretty much exactly the problem described here: http://code.google.com/p/android/issues/detail?id=6191 and until the ViewFlipper issue in 2.1 and 2.2 has been resolved, I'm attempting to customize my own ViewFlipper in the manner described: @Override protected void onDetachedFromWindow() { try { super.onDetachedFromWindow(); } catch (IllegalArgumentException e) { // Call stopFlipping() in order to kick off updateRunning() stopFlipping(); } } But I've never done this sort of thing before and am hoping to get a little guidance (as my own efforts are coming up short). Here's what I have so far. FixedFlipper.java: import android.content.Context; import android.util.AttributeSet; import android.widget.ViewFlipper; public class FixedFlipper extends ViewFlipper{ public FixedFlipper(Context context){ super(context); } public FixedFlipper(Context context, AttributeSet attrs){ super(context, attrs); } @Override protected void onDetachedFromWindow(){ try{ super.onDetachedFromWindow(); }catch(Exception e){ super.stopFlipping(); } } } main.xml: <com.site.TestApp.FixedFlipper style="@style/body" android:id="@+id/flipper"> ... </com.site.TestApp.FixedFlipper> And in my activity, I invoke it like so: FixedFlipper flipper = (FixedFlipper)findViewById(R.id.flipper); It seems like it should be pretty straightforward, but I keep getting this: Binary XML file line #4: Error inflating class com.site.TestApp.FixedFlipper I appreciate any suggestions. I've been chasing my tail for hours trying to figure out what piece of the puzzle I'm missing.

    Read the article

  • Android question - how to prep 100 images to be shown via Fling/Swipe?

    - by fooyee
    I'm totally new to this, been tinkering around for a week. Came up with a simple image viewer app for 2 images. Feature: Left and right swipes will switch the images. Dead simple. What i'd like to do: Have up to 100 images. note: All my images are in my res/drawable folder. They're named image1.png to image100.png I obviously don't want to do: ImageView i = new ImageView(this); i.setImageResource(R.drawable.image1); viewFlipper.addView(i); ImageView i2 = new ImageView(this); i2.setImageResource(R.drawable.image2); viewFlipper.addView(i2); ImageView i3 = new ImageView(this); i3.setImageResource(R.drawable.image3); viewFlipper.addView(i3); all the way to i100. how do I make this into a loop, which is flexible and reads everything from the drawable folder ( and not be limited to 100 images)? source: public class ImageViewTest extends Activity { private static final String LOGID = "CHECKTHISOUT"; private static final int SWIPE_MIN_DISTANCE = 120; private static final int SWIPE_MAX_OFF_PATH = 250; private static final int SWIPE_THRESHOLD_VELOCITY = 200; private GestureDetector gestureDetector; View.OnTouchListener gestureListener; private Animation slideLeftIn; private Animation slideLeftOut; private Animation slideRightIn; private Animation slideRightOut; private ViewFlipper viewFlipper; String message = "Initial Message"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Set up viewflipper viewFlipper = new ViewFlipper(this); ImageView i = new ImageView(this); i.setImageResource(R.drawable.sample_1); ImageView i2 = new ImageView(this); i2.setImageResource(R.drawable.sample_2); viewFlipper.addView(i); viewFlipper.addView(i2); //set up animations slideLeftIn = AnimationUtils.loadAnimation(this, R.anim.slide_left_in); slideLeftOut = AnimationUtils.loadAnimation(this, R.anim.slide_left_out); slideRightIn = AnimationUtils.loadAnimation(this, R.anim.slide_right_in); slideRightOut = AnimationUtils.loadAnimation(this, R.anim.slide_right_out); //put up a brownie as a starter setContentView(viewFlipper); gestureDetector = new GestureDetector(new MyGestureDetector()); } public class MyGestureDetector extends SimpleOnGestureListener { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) return false; // right to left swipe if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { Log.v(LOGID,"right to left swipe detected"); viewFlipper.setInAnimation(slideLeftIn); viewFlipper.setOutAnimation(slideLeftOut); viewFlipper.showNext(); setContentView(viewFlipper); } // left to right swipe else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { Log.v(LOGID,"left to right swipe detected"); viewFlipper.setInAnimation(slideRightIn); viewFlipper.setOutAnimation(slideRightOut); viewFlipper.showPrevious(); setContentView(viewFlipper); } } catch (Exception e) { // nothing } return false; } } // This doesn't work @Override public boolean onTouchEvent(MotionEvent event) { if (gestureDetector.onTouchEvent(event)){ Log.v(LOGID,"screen touched"); return true; } else{ return false; } } }

    Read the article

  • Transition between many Views in ViewFlipper ?

    - by user164589
    Hi guys, I am using "ViewFlipper" for my application. This ViewFlipper includes 5 layouts. I am trying make it that can be changed from current layout to any layout. In other words, it can be changed Layout#1 - Layout#5 or Layout#4 - Layout#1 ..etc. How to make it ? I used showNext() and showPrevious(). It is not better idea for my case. Can I use ViewSwither instead of this case ? Please advice. Can you give example code related this issue ? Thanks in advance.

    Read the article

  • Why does keyboard-slide crash my app?

    - by Brad Hein
    If I physically slide out the keyboard on my Moto Droid A855, it crashes my test app with the stack trace pasted below. I don't understand why? Also, if I start my app with the keyboard out, my app crashes immediately on startup. The app consists of an activity, which contains a viewflipper as the main view layout. The viewflipper contains two linearlayouts... Stack trace: 06-10 21:10:17.652 E/AndroidRuntime( 3785): Uncaught handler: thread main exiting due to uncaught exception 06-10 21:10:17.668 E/AndroidRuntime( 3785): java.lang.IllegalArgumentException: Receiver not registered: android.widget.ViewFlipper$1@447af0b8 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.app.ActivityThread$PackageInfo.forgetReceiverDispatcher(ActivityThread.java:667) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.app.ApplicationContext.unregisterReceiver(ApplicationContext.java:747) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:321) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.widget.ViewFlipper.onDetachedFromWindow(ViewFlipper.java:104) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.view.View.dispatchDetachedFromWindow(View.java:5835) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1076) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1074) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1074) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1074) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.view.ViewRoot.dispatchDetachedFromWindow(ViewRoot.java:1570) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.view.ViewRoot.doDie(ViewRoot.java:2556) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.view.ViewRoot.die(ViewRoot.java:2526) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:218) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.view.Window$LocalWindowManager.removeViewImmediate(Window.java:436) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3498) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3599) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.app.ActivityThread.access$2300(ActivityThread.java:119) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1867) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.os.Handler.dispatchMessage(Handler.java:99) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.os.Looper.loop(Looper.java:123) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at android.app.ActivityThread.main(ActivityThread.java:4363) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at java.lang.reflect.Method.invokeNative(Native Method) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at java.lang.reflect.Method.invoke(Method.java:521) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 06-10 21:10:17.668 E/AndroidRuntime( 3785): at dalvik.system.NativeStart.main(Native Method) 06-10 21:10:17.684 I/Process ( 1017): Sending signal. PID: 3785 SIG: 3

    Read the article

  • Trouble with detecting gestures over ListView

    - by Andrew
    I have an Activity that contains a ViewFlipper. The ViewFlipper includes 2 layouts, both of which are essentially just ListViews. So the idea here is that I have two lists and to navigate from one to the other I would use a horizontal swipe. I have that working. However, what ever list item your finger is on when the swipe begins executing, that item will also be long-clicked. Here is the relevant code I have: public class MyActivity extends Activity implements OnItemClickListener, OnClickListener { private static final int SWIPE_MIN_DISTANCE = 120; private static final int SWIPE_MAX_OFF_PATH = 250; private static final int SWIPE_THRESHOLD_VELOCITY = 200; private GestureDetector mGestureDetector; View.OnTouchListener mGestureListener; class MyGestureDetector extends SimpleOnGestureListener { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) return false; // right to left swipe if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { if (mCurrentScreen != SCREEN_SECONDLIST) { mCurrentScreen = SCREEN_SECONDLIST; mFlipper.setInAnimation(inFromRightAnimation()); mFlipper.setOutAnimation(outToLeftAnimation()); mFlipper.showNext(); updateNavigationBar(); } } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { if (mCurrentScreen != SCREEN_FIRSTLIST) { mCurrentScreen = SCREEN_FIRSTLIST; mFlipper.setInAnimation(inFromLeftAnimation()); mFlipper.setOutAnimation(outToRightAnimation()); mFlipper.showPrevious(); updateNavigationBar(); } } } catch (Exception e) { // nothing } return true; } } @Override public boolean onTouchEvent(MotionEvent event) { if (mGestureDetector.onTouchEvent(event)) return true; else return false; } ViewFlipper mFlipper; private int mCurrentScreen = SCREEN_FIRSTLIST; private ListView mList1; private ListView mList2; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.layout_flipper); mFlipper = (ViewFlipper) findViewById(R.id.flipper); mGestureDetector = new GestureDetector(new MyGestureDetector()); mGestureListener = new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (mGestureDetector.onTouchEvent(event)) { return true; } return false; } }; // set up List1 screen mList1List = (ListView)findViewById(R.id.list1); mList1List.setOnItemClickListener(this); mList1List.setOnTouchListener(mGestureListener); // set up List2 screen mList2List = (ListView)findViewById(R.id.list2); mList2List.setOnItemClickListener(this); mList2List.setOnTouchListener(mGestureListener); } … } If I change the "return true;" statement from the GestureDetector to "return false;", I do not get long-clicks. Unfortunately, I get regular clicks. Does anyone know how I can get around this?

    Read the article

  • ViewFliper in layout

    - by Surabhi Kale
    i am doing one application in android but i have one problem in layout file i am doing by viewFliper here is code <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/Quesiontext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginTop="44dp" android:text="@string/Question" android:textSize="18sp" /> <RadioGroup android:id="@+id/radioGroupOptions" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/Quesiontext" android:layout_marginTop="30dp" > <RadioButton android:id="@+id/optionOne" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="false" android:text="@string/option1" /> <RadioButton android:id="@+id/optionTwo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/option2" /> <RadioButton android:id="@+id/optionthree" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/option3" /> <RadioButton android:id="@+id/optionFour" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/option4" /> </RadioGroup> <TextView android:id="@+id/corrertView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_below="@+id/radioGroupOptions" android:layout_marginRight="48dp" android:text="@string/correct" /> <Button android:id="@+id/btnNext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/corrertView" android:layout_below="@+id/corrertView" android:layout_marginTop="42dp" android:text="@string/Next" android:textSize="16sp" /> <Button android:id="@+id/Btnpervious" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/btnNext" android:layout_alignBottom="@+id/btnNext" android:layout_alignParentLeft="true" android:text="@string/Pervious" android:textSize="16sp" /> <RelativeLayout android:id="@id/layout"//error android:layout_width="match_parent" android:layout_height="match_parent"> <ViewFlipper android:id="@+id/ViewFlipper01" android:layout_width="wrap_content" android:layout_height="wrap_content" > </RelativeLayout> </RelativeLayout> i didnt get it that how i put another button into ViewFliper ..its confusion and generating error...

    Read the article

  • Android: ScrollView in flipper

    - by Manu
    I have a flipper: <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/ParentLayout" xmlns:android="http://schemas.android.com/apk/res/android" style="@style/MainLayout" > <LinearLayout android:id="@+id/FlipperLayout" style="@style/FlipperLayout"> <ViewFlipper android:id="@+id/viewflipper" style="@style/ViewFlipper"> <!--adding views to ViewFlipper--> <include layout="@layout/home1" android:layout_gravity="center_horizontal" /> <include layout="@layout/home2" android:layout_gravity="center_horizontal" /> </ViewFlipper> </LinearLayout> </LinearLayout> The first layout,home1, consists of a scroll view. What should I do to distinguish between the flipping gesture and the scrolling? Presently: if I remove the scroll view, I can swipe across if I add the scroll view, I can only scroll. I saw a suggestion that I should override onInterceptTouchEvent(MotionEvent), but I do not know how to do this. My code, at this moment, looks like this: public class HomeActivity extends Activity { -- declares @Override public void onCreate(Bundle savedInstanceState) { -- declares & preliminary actions LinearLayout layout = (LinearLayout) findViewById(R.id.ParentLayout); layout.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (gestureDetector.onTouchEvent(event)) { return true; } return false; }}); @Override public boolean onTouchEvent(MotionEvent event) { gestureDetector.onTouchEvent(event); return true; } class MyGestureDetector extends SimpleOnGestureListener { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { // http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/ } } } Can anybody please guide me in the right direction? Thank you.

    Read the article

  • What's the best way to check if the view is visible on the window?

    - by bhups
    What's the best way to check if the view is visible on the window? I have a CustomView which is part of my SDK and anybody can add CustomView to their layouts. My CustomView is taking some actions when it is visible to the user periodically. So if view becomes invisible to the user then it needs to stop the timer and when it becomes visible again it should restart its course. But unfortunately there is no certain way of checking if my CustomView becomes visible or invisible to the user. There are few things that I can check and listen to: onVisibilityChange //it is for view's visibility change, and is introduced in new API 8 version so has backward compatibility issue onWindowVisibilityChange //but my CustomView can be part of a ViewFlipper's Views so it can pose issues onDetachedFromWindows //this not as useful onWindowFocusChanged //Again my CustomView can be part of ViewFlipper's views. So if anybody has faced this kind of issues please throw some light.

    Read the article

  • Android - Nesting ViewFlippers

    - by user286285
    Hi, I want to nest several viewflippers. is this possible? I have not been successful thus far. My first tier flips as required but when I flip to the first nested viewflipper its contents appear blank and I can't "flip" it my views are V1 V2 V3 - H1 , H2, H3 One I flip to V3 vertically ... H1 does not appear. where as H is my Horizontal flipper group. Neil

    Read the article

1 2  | Next Page >