public class MainActivity extends Activity {
    private ViewFlipper flipper1, flipper2;
    private List<TBean> mList = new ArrayList<TBean>();
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LinearLayout layout = new LinearLayout(this);
        layout.setOrientation(LinearLayout.VERTICAL);
        flipper1 = new ViewFlipper(this);
        flipper1.setBackgroundColor(0x330000ff);
        flipper2 = new ViewFlipper(this);
        flipper2.setBackgroundColor(0x33ff0000);
        layout.addView(flipper1);
        layout.addView(flipper2);
        initFlipper(flipper1, R.anim.anim_in, R.anim.anim_out);
        initFlipper(flipper2, R.anim.anim_in2, R.anim.anim_out2);
        setContentView(layout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    }
    private void initFlipper(ViewFlipper flipper, int animIn, int animOut) {
        mList.add(new TBean("疯传  家人给2岁孩子喝这个,孩子智力倒退10岁", "https://www.baidu.com/"));
        mList.add(new TBean("哈哈  日本玩家33万甩卖15万张游戏王卡", "http://www.sina.com.cn/"));
        mList.add(new TBean("头条  内疚逃命时没带够,回废墟狂挖30小时", "https://www.google.com.hk/"));
        int size = mList.size();
        for (int i = 0; i < size; i++) {
            final int num = i;
            TextView tv = new TextView(this);
            tv.setText(mList.get(i).Title);
            tv.setTextColor(0xff424954);
            tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
            tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_launcher, 0, 0, 0);
            tv.setGravity(Gravity.CENTER_VERTICAL);
            tv.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(mList.get(num).PageUrl)));
                }
            });
            flipper.addView(tv);
        }
        flipper.setFlipInterval(3000);//间隔时间
        flipper.setInAnimation(this, animIn);
        flipper.setOutAnimation(this, animOut);
        flipper.startFlipping();
    }
    public static class TBean {
        public TBean(String title, String pageUrl) {
            Title = title;
            PageUrl = pageUrl;
        }
        public String Title;
        public String PageUrl;
    }
}