I am trying to remove footer I've set using the same reference I used to set it up. However, nothing happens.
protected void onPostExecute(ArrayList<Recipe> result) {
int CHEF_ID = ChefsRecipeList.this.getIntent().getIntExtra("CHEF_ID", 0);
ListView recipeListView = (ListView)findViewById(android.R.id.list);
View footer = getLayoutInflater().inflate(R.layout.chef_recipe_list_footer, null);
if(!addToExisting){
RecipeManager.getInstance().setRecipeList(result);
View header = getLayoutInflater().inflate(R.layout.chef_recipe_list_header, null);
ImageView loadButton = (ImageView)footer.findViewById(R.id.loadmore);
loadButton.setOnClickListener( new OnClickListener() {
#Override
public void onClick(View v) {
int CHEF_ID = ChefsRecipeList.this.getIntent().getIntExtra("CHEF_ID", 0);
try {
Log.d("NXTLAOD", "http://api.foodnetworkasia.com/api/mobile/get_recipes?chefId="+ChefManager.getInstance().getChef(CHEF_ID).getId()+
"&format=xml&startIndex="+(RecipeManager.getInstance().getRecipeList().size()+1)+"&endIndex="+(RecipeManager.getInstance().getRecipeList().size()+24));
new XMLRecipesParser(true).execute(new URL[] { new URL("http://api.foodnetworkasia.com/api/mobile/get_recipes?chefId="+ChefManager.getInstance().getChef(CHEF_ID).getId()+
"&format=xml&startIndex="+RecipeManager.getInstance().getRecipeList().size()+"&endIndex="+(RecipeManager.getInstance().getRecipeList().size()+24)) } );
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
ImageView chefPhoto = (ImageView)header.findViewById(R.id.chef_photo);
chefPhoto.setImageBitmap(ImageURLLoader.LoadImageFromURL(ChefManager.getInstance().getChef(CHEF_ID).getLargeURL()));
TextView chefBio = (TextView)header.findViewById(R.id.chef_bio);
chefBio.setText(ChefManager.getInstance().getChef(CHEF_ID).getDescription());
recipeListView.addHeaderView(header);
recipeListView.addFooterView(footer);
recipeListView.setAdapter(new RecipeAdapter(ChefsRecipeList.this));
}else{
RecipeManager.getInstance().mergeLists(result);
RecipeAdapter wrapperAdapter=(RecipeAdapter) ((HeaderViewListAdapter)recipeListView.getAdapter()).getWrappedAdapter();
wrapperAdapter.notifyDataSetChanged();
}
if(totalRecipes == RecipeManager.getInstance().getRecipeList().size()){
recipeListView.removeFooterView(footer);
Log.d("FOODREM", "Footer Removed");
}
Log.d("ITCOUNT", totalRecipes+"-"+RecipeManager.getInstance().getRecipeList().size());
updateItemscount();
}
}
You might have to call listView1.setAdapter(adapter) to refresh the listview. If that doesn't work, another solution is to make the height of the footer view to 0px. This is a better solution if you are planning to use the footer view later on again.
You can also set the footer visibility for GONE. To do that, you need to wrap the content of your footer using a linearlayout, then you set the linearlayout visibility to GONE.
In the example bellow I set the visibility of LogoLinearLayout to GONE.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/LogoLinearLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/Logo"
android:src="#drawable/Logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/spacing3"
android:layout_marginBottom="#dimen/spacing3"
android:layout_gravity="center" />
</LinearLayout>
</LinearLayout>
I have seen this type of solution (setting the footer view's height to 0, or setting negative margins..) on many posts related to hiding the footer issue, and it does work, but with 2 issues:
- the list will not respect the transcriptMode="normal" anymore, in the sense that, if the last item is visible and a new item is added to the list, the list will not scroll to the newly added item;
- when keyboard is shown and list size changed, the list again will not show you the last item.
Related
I've got EditTexts in my rows in a ListView. When I tap on one of the EditTexts the soft keyboard appears and the focus jumps to the first EditText in the list instead of staying in the field where I tapped.
Here is a video of it:
https://youtu.be/ZwuFrX-WWBo
I created a completely stripped down app to demonstrate the problem. The full code is here: https://pastebin.com/YT8rxqKa
I'm not doing anything to alter the focus in my code:
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = layoutInflater.inflate(R.layout.cell_textfield, parent, false);
}
TextView label = (TextView) convertView.findViewById(R.id.textview1);
EditText textfield = (EditText) convertView.findViewById(R.id.textview2);
String text = String.format("Row %d", position);
label.setText(text);
textfield.setText(text);
return convertView;
}
I found another post on StackOverflow giving a workaround for this dumb Android behavior, which involves putting an OnFocusChangedListener on all of the textfields so they can retake focus if it's taken from them improperly.
That worked to regain focus, but then I discovered that when a textfield retakes focus the cursor ends up at the start of the text instead of end, which is unnatural and annoying to my users.
Here is a video of that:
https://youtu.be/A35wLqbuIac
Here's the code for that OnFocusChangeListener. It works to fight the stupid Android behavior of moving focus, but the cursor is misplaced after it regains focus.
View.OnFocusChangeListener onFocusChangeListener = new View.OnFocusChangeListener() {
#Override
public void onFocusChange(View view, boolean hasFocus) {
long t = System.currentTimeMillis();
long delta = t - focusTime;
if (hasFocus) { // gained focus
if (delta > minDeltaForReFocus) {
focusTime = t;
focusTarget = view;
}
}
else { // lost focus
if (delta <= minDeltaForReFocus && view == focusTarget) {
focusTarget.post(new Runnable() { // reset focus to target
public void run() {
Log.d("BA", "requesting focus");
focusTarget.requestFocus();
}
});
}
}
}
};
I hate having to put a bandaid on a bandaid on a bandaid to try to get Android to just behave as it would naturally be expected to behave, but I'll take what I can get.
1) Is there something I can do to fix this problem at the source and not have to have the OnFocusChangeListener at all?
2) If (1) isn't possible, then how can I make sure that when I force focus back to the correct field that I make sure the cursor is placed at the end? I tried using setSelection() right after requestFocus() but since the textfield wasn't yet focused the selection is ignored.
Here was my "solution." In short: ListViews are stupid and will always be a total nightmare when EditTexts are involved, so I changed my Fragment/Adapter code to be able to adapt to either a ListView layout or a ScrollView layout. It only works if you have a small number of rows, because the scrollview implementation isn't able to take advantage of lazy-loading and view recycling. Thankfully, any situation wherein I want EditTexts in a ListView, I rarely have more than 20 rows or so.
When inflating my view in my BaseListFragment, I get my layout id via a method that relies on a hasTextFields() method:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(getLayoutId(), container, false);
return view;
}
public boolean hasTextfields() {
return false;
}
public int getLayoutId() {
if (hasTextfields()) {
return R.layout.scrollfragment;
} else {
return R.layout.listfragment;
}
}
In my various subclasses of my BaseListFragment, if I need to have an EditText in one of my fields, I just override the hasTextFields() method to return true and then my fragment/adapter switchs over to using the basic scrollview implementation.
From there, it's a matter of making sure that the Adapter handles the standard ListView actions for both the ListView and the ScrollView scenarios. Like this:
public void notifyDataSetChanged() {
// If scrollContainer is not null, that means we're in a ScrollView setup
if (this.scrollContainer != null) {
// intentionally not calling super
this.scrollContainer.removeAllViews();
this.setupRows();
} else {
// use the real ListView
super.notifyDataSetChanged();
}
}
public void setupRows() {
for (int i = 0; i < this.getCount(); i++) {
View view = this.getView(i, null, this.scrollContainer);
view.setOnClickListener(myItemClickListener);
this.scrollContainer.addView(view);
}
}
One issue that the click listener presented is that a ListView wants an AdapterView.OnItemClickListener, but arbitrary Views inside a ScrollView want a simple View.OnClickListener. So, I made my ItemClickListener also implement View.OnClickListener and then just dispatched the OnClick to the OnItemClick method:
public class MyItemClickListener implements AdapterView.OnItemClickListener, View.OnClickListener {
#Override
public void onClick(View v) {
// You can either have your Adapter set the tag on the View to be its position
// or you could have your click listener use v.getParent() and iterate through
// the children to find the position. I find its faster and easier to have my
// adapter set the Tag on the view.
int position = v.getTag();
this.onItemClick(null, v, config.getPosition(), 0);
}
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// ...
}
}
Then in MyEditTextListFragment, I create the adapter like this:
listener = createClickListener();
adapter = createListAdapter();
if (scrollContainer != null) {
adapter.setScrollContainer(scrollContainer);
adapter.setMenuItemClickListener(listener);
adapter.setupRows();
} else {
getListView().setOnItemClickListener(listener);
getListView().setAdapter(adapter);
}
Here is my scrollfragment.xml for reference:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:clickable="true"
>
<!--
The following LinearLayout as a focus catcher that won't cause the keyboard to
show without it, the virtual keyboard shows up immediately/always which means we
never get to the enjoy the full size of our screen while scrolling, and
that sucks.
-->
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0px"
android:layout_height="0px"/>
<!--
This ListView is still included in the layout but set to visibility=gone. List
fragments require a standard ListView in the layout, so this gets us past that
check and allows us to use the same adapter code in both listview and scrollview
situations.
-->
<ListView android:id="#id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawSelectorOnTop="false"
android:background="#null"
android:layout_alignParentTop="true"
android:descendantFocusability="afterDescendants"
android:visibility="gone"
/>
<!--
This scrollview will act as our fake listview so that we don't have to deal with
all the stupid crap that comes along with having EditTexts inside a ListView.
-->
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="afterDescendants"
>
<LinearLayout
android:id="#+id/scrollContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
</LinearLayout>
</ScrollView>
</RelativeLayout>
Try this once, it worked for me:
public void setCursorPosition() {
focusTarget.requestFocus();
focusTarget.setCursorVisible(true);
other.setCursorVisible(false);
} else {
other.setCursorVisible(true);
focusTarget.setCursorVisible(false);
}
}
So, here's my problem. My recyclerview items have a view at the bottom that I initially set to GONE. Now, when they are clicked I want to make them visible again. So in the onClick method I set the view to Visible. All's fine, but when I scroll down and scroll back up the view is hidden again. I guess it's got something to do with the ViewHolder patter. I want to keep the state as it is, ie, opened. How do I do it? Thanks.
View Holder:
public static class CustomCardViewHolder extends RecyclerView.ViewHolder {
View mCard;
View mFooter;
ImageView mIcon;
TextView mTitle;
TextView mSummary;
public CustomCardViewHolder(View view) {
super(view);
mCard = view.findViewById(R.id.container);
mCard.setTag(this);
mFooter = view.findViewById(R.id.footer); // view to be shown or hidden
mIcon = (ImageView) view.findViewById(R.id.icon);
mTitle = (TextView) view.findViewById(R.id.title);
mSummary = (TextView) view.findViewById(R.id.summary);
}
OnClick:
#Override
public void onClick(View view) {
CustomCardViewHolder holder = (CustomCardViewHolder) view.getTag();
if(holder.mFooter.getVisibility() == View.GONE) {
expand(holder.mFooter); // this is just an animation and I'm setting the visibility to visible
notifyItemChanged(holder.getPosition());
notifyAll();
} else {
collapse(holder.mFooter); // similarly this too
notifyItemChanged(holder.getPosition());
notifyAll();
}
}
Edit: Uploaded code. Also, I tried updating the boolean value of the Item in onClick and enforcing it onBindViewHolder. Problem is I have a sort of fake view(bumper) behind the toolbar. It gets invisible when I expand an item at the bottom of the recyclerview and scroll up again. It gradually starts appearing as I keep scrolling the recyclerview.
My activity xml:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/widget_bumper" />
<include layout="#layout/widget_recyclerview"/>
<include layout="#layout/widget_toolbar" />
</FrameLayout>
and my bumper:
<?xml version="1.0" encoding="utf-8"?>
<View
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/bumper"
android:layout_width="match_parent"
android:layout_height="#dimen/widget_bumper_height"
android:background="?colorPrimary" >
</View>
Yes, you think right, you must keep some flags to determine which item in view is visible and which not. Depending on that you must set View.VISIBLE or View.GONE.
Just give a try and you will succeed. If not please share code I will say what to do.
Updated RecyclerView to the latest library. This fixed the issue.
I have this LinearLayout that is a child of a RelativeLayout along with a ListView among other things:
<LinearLayout
android:id="#+id/color_bar"
android:layout_alignParentBottom="true"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="16dp"
android:padding="0dp"
android:orientation="horizontal"
>
<TextView
android:id="#+id/space_used_bar"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#006688"
android:padding="0dp"
/>
<TextView
android:id="#+id/space_free_bar"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#444444"
android:padding="0dp"
/>
</LinearLayout>
I don't intend to put any text in those TextViews; they are simply there for their background color values. I want to set the width's of these two TextViews programmatically, which I can do, but the problem is that the first time the LinearLayout is presented, it is not drawn. It has no size and I also cannot see the TextViews contained within it. When the user does almost anything (e.g. lock the screen, press the home button, click a list item, select an options item, etc.) the TextViews display properly. It's just that at the first moment when the activity opens, the TextViews and the Layout doesn't show up at all. Does anyone have any idea what the problem might be?
P.S. I have already tried calling invalidate on the LinearLayout as well as the individual TextViews.
EDIT: Here are the callbacks
#Override
public void onCreate(Bundle savedInstanceState)
{
//Log.d(TAG, "onCreate()");
super.onCreate(savedInstanceState);
setContentView(R.layout.browser);
topMenu = getActionBar();
lv = (ListView) findViewById(R.id.file_list);
spaceUsedBar = (TextView) findViewById(R.id.space_used_bar);
spaceFreeBar = (TextView) findViewById(R.id.space_free_bar);
spaceUsed = (TextView) findViewById(R.id.space_used);
spaceFree = (TextView) findViewById(R.id.space_free);
colorBar = (LinearLayout) findViewById(R.id.color_bar);
stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
if (savedInstanceState == null)
{
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
currentDirectory = externalStorageDirectory;
else
{
currentDirectory = new File(ROOT_DIR);
Toast t = Toast.makeText(c, R.string.not_mounted, Toast.LENGTH_SHORT);
t.show();
}
}
else
{
currentDirectory = new File(savedInstanceState.getString("savedPath"));
int savedPosition = savedInstanceState.getInt("savedPosition");
int savedListTop = savedInstanceState.getInt("savedListTop");
if (savedPosition >= 0)
lv.setSelectionFromTop(savedPosition, savedListTop);
}
}
#Override
public void onStart()
{
//Log.d(TAG, "onStart()");
super.onStart();
lv.setOnItemClickListener(this);
lv.setMultiChoiceModeListener(this);
browseTo(currentDirectory);
}
#Override
public void onResume()
{
//Log.d(TAG, "onResume()");
super.onResume();
}
I guess that you haven't redrawn the layout after setting a new width for the TextViews and when the system redraws the layout after the user leaves then returns (locking the screen, home button, orientation change, etc). But I don't see your onCreate() and onResume() code, so it is only a guess...
I'm not sure if this will work but try one of the following (on the textviews). For instance you assign it some initial width or weight, and then adjust it accordingly programmatically when that code executes...
android:layout_width="40dp"
If you want them to take up a percent of the screen instead use the weight attribute:
android:layout_weight="2"
We generate several ListViews that hold info for a user to filter information in another fragment. It works fine, unless you pause and resume the app (say, backgrounding it, or locking the screen). Once you do that, the list can be scrolled, but not clicked.
List generating code:
private View addList(LayoutInflater inflater, ViewGroup container, final FilterValue.SearchCategory type, final String[] labels) {
ArrayAdapter<String> adapter = generateArrayAdapter(inflater, labels, type);
if(adapter == null) {
return null;
}
filterAdapters.add(adapter);
ListView list = (ListView) inflater.inflate(R.layout.on_demand_filter_list, container, false);
list.setAdapter(adapter);
list.setItemsCanFocus(false);
list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
list.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
list.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(final View view, final MotionEvent motionEvent) {
LOG.d(TAG, "NO TOUCHING!");
return false; //To change body of implemented methods use File | Settings | File Templates.
}
});
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
LOG.d(TAG, "onItemClick!");
CheckedTextView textView = (CheckedTextView) view.findViewById(R.id.title);
textView.toggle();
if (textView.isChecked()) {
filterValue.addToSelectedList(labels[i], type);
} else {
filterValue.removeFromSelectedList(labels[i], type);
}
}
});
list.setAdapter(adapter);
list.setVisibility(View.GONE);
filterListContainer.addView(list);
return list;
}
The onTouch listener only exists to ensure the Touch is received. (It is.) The DescendantFocusability appears to have no effect, this bug exists before and after it was added.
Each is tied to a button that shows or hides the list.
titleHeader.setOnClickListener(new View.OnClickListener() {
public void onClick(View clickedView) {
closeNetworkList();
closeGenreList();
titlesOpen = !titlesOpen;
ImageView indicator = (ImageView) clickedView.findViewById(R.id.filter_expansion_indicator_icon);
if (indicator != null) {
if (titlesOpen) {
indicator.setImageResource(R.drawable.arrow_filter_up);
} else {
indicator.setImageResource(R.drawable.arrow_filter_down);
}
}
if (titlesOpen) {
titlesListView.setVisibility(View.VISIBLE);
} else {
titlesListView.setVisibility(View.GONE);
}
}
});
Tapping this button to hide and then show the listView (which was generated with addList) resets something, and the items can be clicked again.
XML for an item row:
<?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="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:padding="8dp"
android:orientation="horizontal">
<CheckedTextView
android:id="#+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#drawable/on_demand_filter_checked_text_sel"
android:gravity="center_vertical"
android:paddingLeft="76dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:drawableLeft="#drawable/checkbox_sel"
android:drawablePadding="14dp"
style="#style/LargeRegular"/>
</LinearLayout>
The focusables are new additions, but neither worked. The problem occurred before they were added.
The ListView itself:
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/list"
android:layout_width="fill_parent"
android:layout_height="275dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:divider="#color/Transparent"
android:descendantFocusability="blocksDescendants"
android:cacheColorHint="#ffffff"/>
I am at my absolute wits' end. No one on my team has a sensible solution to this. It works fine, right up until you pause and resume. We do absolutely nothing that touches the views in resume or pause. Can anyone help? I can provide more detail as needed.
I had similar problem with my app (extended SurfaceView which lost touch events after resume) and resolved it by calling the setFocusable( true ) in the onResume() implementation. Apparently the view didn't get the focus and therefore did not receive the touch events. Not sure whether this is the case here, but worth trying.
Remembered that I had had a similar problem with fragment activities. I had a case when layout requests were blocked, they did not cause actual layout traverse.
I've fixed it in Enroscar library (BaseFragment class) with the following snippet of code in a fragment class:
#Override
public void onStart() {
// ... other staff ...
super.onStart();
/*
XXX I don't know the reason but sometimes after coming back here from other activity all layout requests are blocked. :(
It looks like some concurrency issue or a views tree traversal bug
*/
final View contentView = getActivity().findViewById(android.R.id.content);
if (contentView != null) {
final ViewParent root = contentView.getParent();
if (contentView.isLayoutRequested() && !root.isLayoutRequested()) {
if (DebugFlags.DEBUG_GUI) { Log.i("View", "fix layout request"); }
root.requestLayout();
}
}
}
Can anyone tell me what's wrong with this implementation? All I want to do here is have two overlapping views that swap places when you tap the screen. Unless I'm just using it wrong, View.bringToFront() does nothing?
Below is all the code in my app. Note that I added padding to the 'backView' just to make sure the two were actually overlapping. Indeed I could see both on the screen. While tapping the top view does indeed trigger the onClick method, nothing visibly changes in response to the calls to bringToFront.
public class MainActivity extends Activity implements OnClickListener {
private ImageView frontView;
private ImageView backView;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
frontView = (ImageView) findViewById(com.example.R.id.FrontView);
backView = (ImageView) findViewById(com.example.R.id.BackView);
frontView.setOnClickListener(this);
backView.setOnClickListener(this);
backView.setPadding(10,0,0,0);
}
private boolean flag;
public void onClick(View v) {
if (!flag) {
backView.bringToFront();
}
else {
frontView.bringToFront();
}
flag = !flag;
}
}
and the corresponding layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/FrontView"
android:src="#drawable/front"
/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/BackView"
android:src="#drawable/back"
/>
</RelativeLayout>
Maybe it's the layout I'm using? I'm not sure... I've tried FrameLayout and LinearLayout as well.
I would try swapping content views instead of ImageViews.
Put each imageView in a different layout and then it is easy:
public void onClick(View v) {
if (!flag) {
setContentView(R.layout.main_front);
frontView = (ImageView) findViewById(com.example.R.id.FrontView);
frontView.setOnClickListener(this);
}
else {
setContentView(R.layout.main_back);
backView = (ImageView) findViewById(com.example.R.id.BackView);
backView.setOnClickListener(this);
}
flag = !flag;
}
There are a couple of Components that you can use that do this for you.
ViewAnimator, ViewFlipper and ViewSwitcher. You can set the animations you require etc and they hand the rest.
here's one example.
http://www.androidpeople.com/android-viewflipper-example/
Given your example, do you have to call invalidate() on the parent after you've called bringToFront() ?