Created
September 28, 2016 08:09
-
-
Save maydin/0b31c6370cb9c25a78cb64d20b9a6c4c to your computer and use it in GitHub Desktop.
MainActivity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity implements View.OnClickListener{ | |
TextSwitcher myTextSwitcher; | |
AnimationSet as; | |
AppCompatButton button; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
myTextSwitcher = (TextSwitcher) this.findViewById(R.id.text_switcher); | |
button = (AppCompatButton) this.findViewById(R.id.button); | |
button.setOnClickListener(this); | |
myTextSwitcher.setFactory(new ViewSwitcher.ViewFactory() { | |
@Override | |
public View makeView() { | |
LayoutInflater inflater = LayoutInflater.from(MainActivity.this); | |
AppCompatTextView textView = (AppCompatTextView) inflater.inflate(R.layout.textview, null); | |
return textView; | |
} | |
}); | |
final Animation in = new AlphaAnimation(0.0f, 1.0f); | |
final Animation out = new AlphaAnimation(1.0f, 0.0f); | |
in.setDuration(100); | |
out.setDuration(100); | |
as = new AnimationSet(true); | |
as.addAnimation(out); | |
as.addAnimation(in); | |
} | |
@Override | |
public void onClick(View view) { | |
myTextSwitcher.setText("Bye World"); | |
myTextSwitcher.startAnimation(as); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment