即时聊天社交软件(二)

来源:互联网 发布:淘宝家具安装价格 编辑:程序博客网 时间:2024/05/01 20:59

即时聊天社交软件(二)

这次做一些关于android控件的设置
当用户登陆成功后的界面设置 :
我打算将这个activity设置成有下拉刷新和左菜单栏功能的activity
1. 下拉刷新控件 :
使用pulltorefresh控件 可以自行百度导入
2.左侧菜单栏 :
使用drawerlayout布局:
下面是布局文件:

<?xml version="1.0" encoding="utf-8"?><android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/draw_layout"    android:layout_width="match_parent"    android:layout_height="match_parent" >    <LinearLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        android:orientation="vertical" >        <com.handmark.pulltorefresh.library.PullToRefreshListView            android:id="@+id/mylv"            android:layout_width="fill_parent"            android:layout_height="fill_parent" >        </com.handmark.pulltorefresh.library.PullToRefreshListView>    </LinearLayout>    <!-- 侧拉视图 --> <LinearLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        android:background="#fff"        android:layout_gravity="start">        <ListView            android:id="@+id/lv1"            android:layout_width="match_parent"            android:layout_height="match_parent"            android:divider="@null"            android:text="DrawerLayout" />    </LinearLayout></android.support.v4.widget.DrawerLayout>

下面是java文件:

package com.ws.talk;import java.util.ArrayList;import com.example.qq.R;import com.handmark.pulltorefresh.extras.viewpager.PullToRefreshViewPager;import com.handmark.pulltorefresh.library.PullToRefreshListView;import android.app.Activity;import android.os.Bundle;import android.support.v4.widget.DrawerLayout;import android.view.View;import android.widget.ArrayAdapter;import android.widget.ListView;public class talk extends Activity {    PullToRefreshListView lv;     private ArrayAdapter<String> adapter;    private DrawerLayout drawerLayout;    private ListView lv1;    private ArrayList<String>arrayList;    private ArrayAdapter<String> ad1;    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.talk);        lv = (PullToRefreshListView) findViewById(R.id.mylv);//下拉刷新控件        adapter = new ArrayAdapter<String>(this,                android.R.layout.simple_list_item_1, new String[] { "a", "b",                        "c" });//下拉刷新的适配器        lv.setAdapter(adapter);//开始        drawerLayout=(DrawerLayout) findViewById(R.id.draw_layout);//左侧菜单栏控件        lv1=(ListView) findViewById(R.id.lv1);        arrayList=new ArrayList<String>();        for (int i = 0; i < 5; i++) {            arrayList.add("自定义"+i);        }        ad1=new ArrayAdapter<String>(talk.this,android.R.layout.simple_list_item_1,arrayList);        //simple_list_item_1不能用simple_list_item_2替换 这个问题百度了好久 结果就是自作聪明换成了item2        lv1.setAdapter(ad1);//给listview设置adapter    }}

我这里基本都给出了注释,请仔细查看

下面是我分享的pull to refresh 的包 直接导入就可以了
http://yun.baidu.com/share/link?shareid=246519337&uk=1311862808

0 0
原创粉丝点击