views:

290

answers:

1

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.

A: 

Try to change yuor main.xml in this way:

<view
  class="com.site.TestApp.FixedFlipper"
  style="@style/body" 
  android:id="@+id/flipper"
    ...
</view>
Francesco
That looks like it fixed it. Thanks!