• 7

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Animation when changing textview

I currently use a major workaround and have two activities switching each time I change the text on a TextView. I am using this code:


Is it possible to do this in one Activity? It's kind of annoying having two Activities with the exact same content just so that I can use animations ;)

Thanks! Please ask if you don't understand my Question!

You can use a TextSwitcher to have animations when changing the text in a TextView.

A TextSwitcher is just a special kind of ViewSwitcher, and as such, it lets you provide two Views from which to animate between. When you call setText(), it updates the text of the next TextView and then animates that one into the screen, and the current one out. The old TextView is then designated as the 'next' TextView and the process repeats.

You can specify the Views using setFactory(...) or just simply add two TextViews to it with addView(...).

// get a TextSwitcher view; instantiate in code or resolve from a layout/XML
TextSwitcher textSwitcher = new TextSwitcher(context);

// specify the in/out animations you wish to use
textSwitcher.setInAnimation(context, R.anim.slide_in_left);
textSwitcher.setOutAnimation(context, R.anim.slide_out_right);

// provide two TextViews for the TextSwitcher to use
// you can apply styles to these Views before adding
textSwitcher.addView(new TextView(context));
textSwitcher.addView(new TextView(context));

// you are now ready to use the TextSwitcher
// it will animate between calls to setText
  • 68
Reply Report