and thanks for your help. I am trying to use a ViewAnimator tho show different views on screen.
So:
I create the VievAnimator,
I add 2 Views (LinearLayouts in this case) to ViewAnimator,
I set setContentView(viewAnimator);
I call viewAnimator.showNext();
But nothing shows on screen...
public class MainActivity extends Activity {
public DataBaseHelper db;
public EditText enter;
public TextView tv;
public ArrayList<String> listWord;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ViewAnimator viewAnimator = new ViewAnimator(this);
LayoutInflater inflater = (LayoutInflater)this.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout front =(LinearLayout) inflater.inflate(R.layout.front,viewAnimator );
LinearLayout back =(LinearLayout) inflater.inflate(R.layout.back,viewAnimator );
viewAnimator.addView(front);
viewAnimator.addView(back);
setContentView(viewAnimator);
viewAnimator.showNext();
Any help very much appreciated!
The problem is in the following lines:
because when you provide
viewAnimatoras root view during inflation, then the same root view is returned, and in your code causing theClassCastExceptionbecauseViewAnimatorcannot be cast'ed intoLinearLayout.For your reference:
Simply provide null as root view and it work just fine. For example: