Android之TextSwitcher
来源:互联网 发布:全民wifi网络异常 编辑:程序博客网 时间:2024/05/23 19:12
一. 简单示例
src
public class AndroidUIActivity extends Activity {// 索引private int index;// 文本数组private String[] poemArray = { "we", "are", "good", "friends" };/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);//定义文字切换器final TextSwitcher ts = (TextSwitcher) findViewById(R.id.textSwitcher1);//定义视图显示工厂,并设置ts.setFactory(new ViewFactory() {public View makeView() {TextView tv =new TextView(AndroidUIActivity.this);tv.setTextSize(32);tv.setTextColor(Color.GREEN);return tv;}});// 设置图片来源ts.setText(poemArray[index]);// 设置点击监听器ts.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {// 点击会切换图片index++;if (index >= poemArray.length) {index = 0;}ts.setText(poemArray[index]);}});// 设置切入动画ts.setInAnimation(AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.slide_in_left));// 设置切出动画ts.setOutAnimation(AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.slide_out_right));}}
main.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextSwitcher android:id="@+id/textSwitcher1" android:layout_width="match_parent" android:layout_height="wrap_content" > </TextSwitcher></LinearLayout>
二. 运行结果
启动
点击we后(只能点击文字)
- Android之TextSwitcher
- android 之 TextSwitcher 学习
- Android之TextSwitcher详解
- android控件 之 TextSwitcher
- Android之TextSwitcher----ImageSwitcher
- android-TextSwitcher
- Android TextSwitcher
- [Android] TextSwitcher
- Android初级之组件基础10-TextSwitcher
- Android UI之ImageSwitcher && TextSwitcher 实现图文翻页
- AndroidUI组件之TextSwitcher
- android控件17 TextSwitcher
- Android ViewSwitcher、TextSwitcher、ImageSwitcher
- TextSwitcher
- TextSwitcher
- Android TextSwitcher - 文本切换器
- Android----ViewFlipper,ViewSwitcher(ImageSwitcher,TextSwitcher)
- Android TextSwitcher官方使用教程
- 批量更新重复数据
- 几道题目
- 【国外电子与通信教材系列】 系列图书汇总 目前19本
- 不同类型之间的转换
- ubuntu下的eclipse支持中文---GBK编码【本人验证】
- Android之TextSwitcher
- 简明python教程
- 增量型博客
- 字符串函数
- huffman表在xvid中的应用
- python之py2exe
- oracle中 connect by prior 递归算法,connect_by_root,sys_connect_by_path,connect_by_isleaf,CONNECT_BY_ISCYC
- 接口实现类的问题
- java实现几个2的n次方和的分解