I have a class that extends Activity and implements ViewFactory.
I have found some tutorials and code examples that show how to setup a textSwitcher and imageSwitcher.
With both examples you have to create:
public View makeView() {
return x;
}
Where x is either the textView or ImageView.
Here is an example of what I tried to use:
@Override
public View makeView() {
ImageView iView = new ImageView(this);
iView.setScaleType(ImageView.ScaleType.FIT_CENTER);
iView.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
iView.setBackgroundColor(0xFFFFFFFF);
TextView t = new TextView(this);
t.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
t.setTextSize(36);
return iView;
}
I can only return one of the views so I get a forced close when I try to run it with a textSwitcher called.
Any ideas? Is there a better way to do this?
Thank you,
Neil
As Stéphane stated before me, create an inner class implementing ViewFactory
Then when calling the TextSwitcher from xml and setting the factory, instead of
mSwitcher.setFactory(this);, usemSwitcher.setFactory(new TextSwitcherFactory());e.g.