package com.bwie.test;

import java.nio.channels.SelectableChannel;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Matrix;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.DisplayMetrics;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
import android.widget.TextView;

public class MainActivity extends FragmentActivity implements OnClickListener,
        OnPageChangeListener {

    private List<Fragment> list;
    private TextView t1, t2, t3, t4;
    private MyFragmentZx  myFragmentZx;
    private MyFragmentRe  myFragmentRe;
    private MyFragmentBk  myFragmentBk;
    private MyFragmentTj  myFragmentTj;
    private ImageView cursor;  
    private int bmpw = 0; // 游标宽度  
    private int offset = 0;// // 动画图片偏移量  
    private int currIndex = 0;// 当前页卡编号  


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        getId();
        getInfo();
        Moves();
        vp = (ViewPager) findViewById(R.id.viewpager);
        vp.setAdapter(adapter);
        vp.setOnPageChangeListener(this);
        vp.setCurrentItem(0);
    }

    private void Moves() {
        // TODO Auto-generated method stub
         // 初始化动画  
        cursor = (ImageView) findViewById(R.id.imageView1);  
        bmpw = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)  
                .getWidth();// 获取图片宽度  
 
        DisplayMetrics dm = new DisplayMetrics();  
        getWindowManager().getDefaultDisplay().getMetrics(dm);  
        int screenW = dm.widthPixels;// 获取分辨率宽度  
        offset = (screenW / list.size() - bmpw) / 2;// 计算偏移量  
        Matrix matrix = new Matrix();  
        matrix.postTranslate(offset, 0);  
        cursor.setImageMatrix(matrix);// 设置动画初始位置  
    }

    private void getInfo() {
        // TODO Auto-generated method stub
        list = new ArrayList<Fragment>();
        myFragmentZx=new  MyFragmentZx();
        myFragmentRe=new  MyFragmentRe();
        myFragmentBk=new  MyFragmentBk();
        myFragmentTj=new  MyFragmentTj();
        
        list.add(myFragmentZx);
        list.add(myFragmentRe);
        list.add(myFragmentBk);
        list.add(myFragmentTj);
    }

    private void getId() {
        t1 = (TextView) findViewById(R.id.text01);
        t2 = (TextView) findViewById(R.id.text02);
        t3 = (TextView) findViewById(R.id.text03);
        t4 = (TextView) findViewById(R.id.text04);
        t1.setOnClickListener(this);
        t2.setOnClickListener(this);
        t3.setOnClickListener(this);
        t4.setOnClickListener(this);
        t1.setTextColor(Color.GREEN);
        t2.setTextColor(Color.BLACK);
        t3.setTextColor(Color.BLACK);
        t4.setTextColor(Color.BLACK);
        
    }

    FragmentPagerAdapter adapter = new FragmentPagerAdapter(
            getSupportFragmentManager()) {

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return list.size();
        }

        @Override
        public Fragment getItem(int arg0) {
            // TODO Auto-generated method stub
            return list.get(arg0);
        }
    };
    private ViewPager vp;

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch (v.getId()) {
        case R.id.text01:
            vp.setCurrentItem(0);
            break;
        case R.id.text02:
            vp.setCurrentItem(1);
            break;
        case R.id.text03:
            vp.setCurrentItem(2);
            break;
        case R.id.text04:
            vp.setCurrentItem(3);
            break;

        default:
            break;
        }
    }

    @Override
    public void onPageScrollStateChanged(int arg0) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onPageScrolled(int arg0, float arg1, int arg2) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onPageSelected(int arg0) {
        // TODO Auto-generated method stub
        Select(arg0);
    }

    private void Select(int position) {
        // TODO Auto-generated method stub
            int one = offset * 2 + bmpw;// 页卡1 -> 页卡2 偏移量  
            int two = one * 2;// 页卡1 -> 页卡3 偏移量  
            int three=two+one;
            Animation animation = null;
        switch (position) {
          
        case 0:
            t1.setTextColor(Color.GREEN);
            t2.setTextColor(Color.BLACK);
            t3.setTextColor(Color.BLACK);
            t4.setTextColor(Color.BLACK);
             if (currIndex == 1) {  
                 animation = new TranslateAnimation(one, 0, 0, 0);  
             } else if (currIndex == 2) {  
                 animation = new TranslateAnimation(two, 0, 0, 0);  
             }else if(currIndex==3){
                 animation = new TranslateAnimation(three, 0, 0, 0);  
             }
            break;
        case 1:
            t1.setTextColor(Color.BLACK);
            t2.setTextColor(Color.GREEN);
            t3.setTextColor(Color.BLACK);
            t4.setTextColor(Color.BLACK);
            if (currIndex == 0) {  
                animation = new TranslateAnimation(offset, one, 0, 0);  
            } else if (currIndex == 2) {  
                animation = new TranslateAnimation(two, one, 0, 0);  
            }else if(currIndex==3){
                animation = new TranslateAnimation(three, one, 0, 0);  
            }  
            break;
        case 2:
            t1.setTextColor(Color.BLACK);
            t2.setTextColor(Color.BLACK);
            t3.setTextColor(Color.GREEN);
            t4.setTextColor(Color.BLACK);
             if (currIndex == 0) {  
                 animation = new TranslateAnimation(offset, two, 0, 0);  
             } else if (currIndex == 1) {  
                 animation = new TranslateAnimation(one, two, 0, 0);  
             }else if(currIndex==3){
                 animation = new TranslateAnimation(three, two, 0, 0);  
             }  
            break;
        case 3:
            t1.setTextColor(Color.BLACK);
            t2.setTextColor(Color.BLACK);
            t3.setTextColor(Color.BLACK);
            t4.setTextColor(Color.GREEN);
             if (currIndex == 0) {  
                 animation = new TranslateAnimation(offset, three, 0, 0);  
             } else if (currIndex == 1) {  
                 animation = new TranslateAnimation(one, three, 0, 0);  
             }else if(currIndex==2){
                 animation = new TranslateAnimation(two, three, 0, 0);  
             }  
            break;

        default:
            break;
        }
         currIndex = position;  
         animation.setFillAfter(true);// True:图片停在动画结束位置  
         animation.setDuration(300);  
         cursor.startAnimation(animation);
    }

}
每个Fragment的页面
package com.bwie.test;

import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import com.bwie.adapter.MyAdapter;
import com.bwie.xlistview.XListView;
import com.bwie.xlistview.XListView.IXListViewListener;
import com.bwie.xlistview.XListView.OnXScrollListener;
import com.bwies.bean.All;
import com.bwies.bean.Next;
import com.bwies.bean.Next_list;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
import com.thoughtworks.xstream.XStream;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class MyFragmentZx extends Fragment implements IXListViewListener{
    
    private XListView xv;
    String url="http://www.oschina.net/action/api/news_list";
    int  index=0;
    @Override
    public View onCreateView(LayoutInflater inflater,
            @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        View  view=inflater.inflate(R.layout.item, null);
        
        xv = (XListView) view.findViewById(R.id.my_xlist);
        xv.setPullLoadEnable(true);
        xv.setPullRefreshEnable(true);
        xv.setXListViewListener(this);
        
        getInfo(url,1,1,10);
        
        return view;
    }

    

    private void getInfo(String urls,int i,int j,int k) {
        // TODO Auto-generated method stub
        HttpUtils   httpUtils=new   HttpUtils();
        RequestParams    params=new    RequestParams();
        params.addBodyParameter("catalog",i+"");
        params.addBodyParameter("pageIndex",j+"");
        params.addBodyParameter("pageSize", k+"");
        httpUtils.send(HttpMethod.POST,urls, params, new RequestCallBack<String>() {

            @Override
            public void onFailure(HttpException arg0, String arg1) {
                // TODO Auto-generated method stub
                
            }

            @Override
            public void onSuccess(ResponseInfo<String> arg0) {
                // TODO Auto-generated method stub
            
                
                XStream  xStream=new  XStream();
                
                xStream.processAnnotations(All.class);
                
               All all = (All) xStream.fromXML(arg0.result);
                
                Next_list newslist =all.getNewslist();            
                
                MyAdapter adapter=new MyAdapter(getActivity(),newslist.getNews());
                
                xv.setAdapter(adapter);
            }
        });
    }



    @Override
    public void onRefresh() {
        // TODO Auto-generated method stub
        index++;
        getInfo(url,1,index,10);
        onload();
    }
    @Override
    public void onLoadMore() {
        // TODO Auto-generated method stub
        index++;
        getInfo(url,1,index,10);
        onload();
    }
    
    private void onload() {
        // TODO Auto-generated method stub
        xv.stopRefresh();

        xv.stopLoadMore();
        // 设置日期格式
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // 获取当前系统时间
        String nowTime = df.format(new Date(System.currentTimeMillis()));
        // 释放时提示正在刷新时的当前时间
        xv.setRefreshTime(nowTime);
    }

}

package com.bwie.test;

import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import com.bwie.adapter.MyAdapter;
import com.bwie.xlistview.XListView;
import com.bwie.xlistview.XListView.IXListViewListener;
import com.bwie.xlistview.XListView.OnXScrollListener;
import com.bwies.bean.All;
import com.bwies.bean.Next_list;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
import com.thoughtworks.xstream.XStream;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class MyFragmentRe extends Fragment implements IXListViewListener{
    
    private XListView xv;
    String url="http://www.oschina.net/action/api/news_list";
    int  index=0;
    @Override
    public View onCreateView(LayoutInflater inflater,
            @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        View  view=inflater.inflate(R.layout.item, null);
        
        xv = (XListView) view.findViewById(R.id.my_xlist);
        xv.setPullLoadEnable(true);
        xv.setPullRefreshEnable(true);
        xv.setXListViewListener(this);
        
        getInfo(url,1,1,10);
        
        return view;
    }

    

    private void getInfo(String urls,int i,int j,int k) {
        // TODO Auto-generated method stub
        HttpUtils   httpUtils=new   HttpUtils();
        RequestParams    params=new    RequestParams();
        params.addBodyParameter("catalog",i+"");
        params.addBodyParameter("pageIndex",j+"");
        params.addBodyParameter("pageSize", k+"");
        params.addBodyParameter("week","");
        httpUtils.send(HttpMethod.POST,urls, params, new RequestCallBack<String>() {

            @Override
            public void onFailure(HttpException arg0, String arg1) {
                // TODO Auto-generated method stub
                
            }

            @Override
            public void onSuccess(ResponseInfo<String> arg0) {
                // TODO Auto-generated method stub
            
                
                XStream  xStream=new  XStream();
                
                xStream.processAnnotations(All.class);
                
               All all = (All) xStream.fromXML(arg0.result);
                
                Next_list newslist =all.getNewslist();            
                
                MyAdapter adapter=new MyAdapter(getActivity(),newslist.getNews());
                
                xv.setAdapter(adapter);
            }
        });
    }



    @Override
    public void onRefresh() {
        // TODO Auto-generated method stub
        index++;
        getInfo(url,1,index,10);
        onload();
    }
    @Override
    public void onLoadMore() {
        // TODO Auto-generated method stub
        index++;
        getInfo(url,1,index,10);
        onload();
    }
    
    private void onload() {
        // TODO Auto-generated method stub
        xv.stopRefresh();

        xv.stopLoadMore();
        // 设置日期格式
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // 获取当前系统时间
        String nowTime = df.format(new Date(System.currentTimeMillis()));
        // 释放时提示正在刷新时的当前时间
        xv.setRefreshTime(nowTime);
    }

}

package com.bwie.test;

import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import com.biew.blogs.Blogs;
import com.biew.blogs.One;
import com.bwie.adapter.MyAdapter;
import com.bwie.adapter.MyBAdapter;
import com.bwie.xlistview.XListView;
import com.bwie.xlistview.XListView.IXListViewListener;
import com.bwie.xlistview.XListView.OnXScrollListener;
import com.bwies.bean.All;
import com.bwies.bean.Next_list;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
import com.thoughtworks.xstream.XStream;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


public class MyFragmentBk extends Fragment implements IXListViewListener{
    
    private XListView xv;
    String url="http://www.oschina.net/action/api/blog_list";
    int  index=0;
    
    @Override
    public View onCreateView(LayoutInflater inflater,
            @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        View  view=inflater.inflate(R.layout.item, null);
        
        xv = (XListView) view.findViewById(R.id.my_xlist);
        xv.setPullLoadEnable(true);
        xv.setPullRefreshEnable(true);
        xv.setXListViewListener(this);
        
        getInfo("latest",1,10);
        
        return view;
    }

    private void getInfo(String str,int j,int k) {
        // TODO Auto-generated method stub
        HttpUtils   httpUtils=new   HttpUtils();
        RequestParams    params=new    RequestParams();
        params.addBodyParameter("type",str);
        params.addBodyParameter("pageIndex",j+"");
        params.addBodyParameter("pageSize", k+"");
        
        httpUtils.send(HttpMethod.POST,url, params, new RequestCallBack<String>() {

            @Override
            public void onFailure(HttpException arg0, String arg1) {
                // TODO Auto-generated method stub
                
            }

            @Override
            public void onSuccess(ResponseInfo<String> arg0) {
                // TODO Auto-generated method stub
                
            Log.i("TAG", arg0.result.toString());
            XStream  xStream=new  XStream();
        
            xStream.processAnnotations(One.class);
            
            One fromXML = (One) xStream.fromXML(arg0.result);
            
            
            List<Blogs> list = fromXML.blogs.blog;
            
            
            
            MyBAdapter  myBAdapter=new   MyBAdapter(getActivity(), list);
            xv.setAdapter(myBAdapter);
                
            }
        });
    }
    

    @Override
    public void onRefresh() {
        // TODO Auto-generated method stub
        index++;
        getInfo( "latest", index, 10);
        load();
    }
    @Override
    public void onLoadMore() {
        // TODO Auto-generated method stub
        index++;
        getInfo( "latest", index, 10);
        load();
    }
    
    
    public void load(){
        
        xv.stopRefresh();
        xv.stopLoadMore();
        
//        SimpleDateFormat  df=new   SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        String format = df.format(new Date(System.currentTimeMillis()));
//        
//        xv.setRefreshTime(format);
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // 获取当前系统时间
        String nowTime = df.format(new Date(System.currentTimeMillis()));
        // 释放时提示正在刷新时的当前时间
        xv.setRefreshTime(nowTime);
        
    }

}

package com.bwie.test;

import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import com.biew.blogs.Blogs;
import com.biew.blogs.One;
import com.bwie.adapter.MyBAdapter;
import com.bwie.xlistview.XListView;
import com.bwie.xlistview.XListView.IXListViewListener;
import com.bwie.xlistview.XListView.OnXScrollListener;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
import com.thoughtworks.xstream.XStream;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class MyFragmentTj extends Fragment implements IXListViewListener{
    
    private XListView xv;
    String url="http://www.oschina.net/action/api/blog_list";
    int  index=0;
    
    @Override
    public View onCreateView(LayoutInflater inflater,
            @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        View  view=inflater.inflate(R.layout.item, null);
        
        xv = (XListView) view.findViewById(R.id.my_xlist);
        xv.setPullLoadEnable(true);
        xv.setPullRefreshEnable(true);
        xv.setXListViewListener(this);
        
        getInfo("recommend",1,10);
        
        return view;
    }

    private void getInfo(String str,int j,int k) {
        // TODO Auto-generated method stub
        HttpUtils   httpUtils=new   HttpUtils();
        RequestParams    params=new    RequestParams();
        params.addBodyParameter("type",str);
        params.addBodyParameter("pageIndex",j+"");
        params.addBodyParameter("pageSize", k+"");
        
        httpUtils.send(HttpMethod.POST,url, params, new RequestCallBack<String>() {

            @Override
            public void onFailure(HttpException arg0, String arg1) {
                // TODO Auto-generated method stub
                
            }

            @Override
            public void onSuccess(ResponseInfo<String> arg0) {
                // TODO Auto-generated method stub
            XStream  xStream=new  XStream();
        
            xStream.processAnnotations(One.class);
            
            One fromXML = (One) xStream.fromXML(arg0.result);
            
            List<Blogs> list = fromXML.blogs.blog;
            
            MyBAdapter  myBAdapter=new   MyBAdapter(getActivity(), list);
            xv.setAdapter(myBAdapter);
                
            }
        });
    }
    

    @Override
    public void onRefresh() {
        // TODO Auto-generated method stub
        index++;
        getInfo( "recommend", index, 10);
        load();
    }
    @Override
    public void onLoadMore() {
        // TODO Auto-generated method stub
        index++;
        getInfo( "recommend", index, 10);
        load();
    }
    
    
    public void load(){
        
        xv.stopRefresh();
        
        xv.stopLoadMore();
        
//        SimpleDateFormat  df=new   SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        String format = df.format(new Date(System.currentTimeMillis()));
//        
//        xv.setRefreshTime(format);
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // 获取当前系统时间
        String nowTime = df.format(new Date(System.currentTimeMillis()));
        // 释放时提示正在刷新时的当前时间
        xv.setRefreshTime(nowTime);
        
    }

}

XListView实现上拉加载新数据和下拉刷新数据

xlistview_footer.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="wrap_content" >

    <RelativeLayout
        android:id="@+id/xlistview_footer_content"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="10dp" >

        <ProgressBar
            android:id="@+id/xlistview_footer_progressbar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:visibility="invisible" />

        <TextView
            android:id="@+id/xlistview_footer_hint_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="@string/xlistview_footer_hint_normal" />
    </RelativeLayout>

</LinearLayout>

xlistview_header.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="wrap_content"
    android:gravity="bottom" >

    <RelativeLayout
        android:id="@+id/xlistview_header_content"
        android:layout_width="fill_parent"
        android:layout_height="60dp" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:gravity="center"
            android:orientation="vertical" android:id="@+id/xlistview_header_text">

            <TextView
                android:id="@+id/xlistview_header_hint_textview"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/xlistview_header_hint_normal" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="3dp" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/xlistview_header_last_time"
                    android:textSize="12sp" />

                <TextView
                    android:id="@+id/xlistview_header_time"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="12sp" />
            </LinearLayout>
        </LinearLayout>

        <ImageView
            android:id="@+id/xlistview_header_arrow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@id/xlistview_header_text"
            android:layout_centerVertical="true"
            android:layout_marginLeft="-35dp"
            android:src="@drawable/xlistview_arrow" />

        <ProgressBar
            android:id="@+id/xlistview_header_progressbar"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_alignLeft="@id/xlistview_header_text"
            android:layout_centerVertical="true"
            android:layout_marginLeft="-40dp"
            android:visibility="invisible" />
    </RelativeLayout>

</LinearLayout>

主页面的布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.bwie.test.MainActivity"
    android:orientation="vertical" >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:orientation="horizontal">
      <RadioGroup
          android:id="@+id/main_radio"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_gravity="bottom|center_horizontal"
          android:layout_weight="0.28"
          android:gravity="bottom"
          android:orientation="horizontal" >

         <RadioButton
             android:id="@+id/text01"
             android:layout_height="fill_parent"
             android:layout_weight="1"
             android:button="@null"
             android:gravity="center"
             android:text="资讯" />

        <RadioButton
            android:id="@+id/text02"
            android:layout_height="fill_parent"
            android:text="热点"
            android:button="@null"
            android:layout_weight="1"
            android:gravity="center"
             />

        <RadioButton
            android:id="@+id/text03"
            android:layout_height="fill_parent"
            android:text="博客"
            android:button="@null"
            android:layout_weight="1"
            android:gravity="center"
             />

        <RadioButton
            android:id="@+id/text04"
            android:layout_height="fill_parent"
            android:text="推荐"
            android:button="@null"
            android:layout_weight="1"
            android:gravity="center"
           />
      
     
  </RadioGroup>
 
      </LinearLayout>


  <ImageView
      android:id="@+id/imageView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginLeft="15dp"
      android:src="@drawable/b" />
 
      <android.support.v4.view.ViewPager
          android:id="@+id/viewpager"
          android:layout_width="match_parent"
          android:layout_height="fill_parent"
          android:layout_weight="1.16" />

</LinearLayout>

添加适配器

package com.bwie.adapter;

import java.util.List;

import com.bwie.test.R;
import com.bwies.bean.Next;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MyAdapter extends BaseAdapter {
    Context context;
    List<Next> list;
    public MyAdapter(Context context, List<Next> list) {
        super();
        this.context = context;
        this.list = list;
    }
    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return list.size();
    }


    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return list.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if(convertView==null){
            viewHolder=new ViewHolder();
            convertView=LayoutInflater.from(context).inflate(R.layout.listview_item, null);
            viewHolder.t1=(TextView) convertView.findViewById(R.id.text_title);
            viewHolder.t2=(TextView) convertView.findViewById(R.id.text_sub);
            viewHolder.t3=(TextView) convertView.findViewById(R.id.text_tt);
            convertView.setTag(viewHolder);
        }else{
            viewHolder=(ViewHolder) convertView.getTag();
        }
           viewHolder.t1.setText(list.get(position).getTitle());
           viewHolder.t2.setText(list.get(position).getBody());
           viewHolder.t3.setText(list.get(position).getAuthor()+"    "+list.get(position).getPubDate()+"       "+list.get(position).getCommentCount());
        
           return convertView;
    }
    class ViewHolder{
        TextView t1,t2,t3;
    }
}

自己写的bean记得加注解啊

@XStreamAlias("oschina")最外面的那个标签

@XStreamAlias("blogs")里面包含对象的那个标签

@XStreamImplicit(itemFieldName="blog")这是那个要对象的标签