Here is a simplified code example of what I’m trying to do:
public class main extends Activity {
public myFlipper flipper;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
flipper = (myFlipper) findViewById(R.id.viewFlipper1);
}
class myFlipper extends ViewFlipper
{
public myFlipper(Context context)
{
super(context);
// TODO Auto-generated constructor stub
}
}
}
Java throws a classCastException when I try to do this, what am I doing wrong?
I figured it out to those of you who are interested.
You need to add a constructor that allows for Layout attributes in your custom view class. Like so:
And you need to follow Cristian´s example as well. Then it should work 🙂