android: How to set a listener that fires when my ViewFlipper shows a new child
Posted
by Joseph Cheek
on Stack Overflow
See other posts from Stack Overflow
or by Joseph Cheek
Published on 2010-04-20T02:50:57Z
Indexed on
2010/04/20
2:53 UTC
Read the original article
Hit count: 701
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?
© Stack Overflow or respective owner