(droid分享)新浪微博开发系列【七】之查看我的好友和粉丝

此部分为显示我的全部好友和我的粉丝,点击上面的按钮可以进行切换。在此说明一下,可能代码里调用一些方法在本篇中没有,但是全部在我的代码里,也不要索取图片,要看全部代码的请移步http://blog.csdn.net/gaojin1991/article/details/8022213<?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"
android:background="#00ffffff">
<!-- 微博首页标题部分 -->
<LinearLayout
   android:id="@+id/frendsTitle"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:orientation="vertical"
   android:background="#BB768e95">   
   
   <TextView
      android:id="@+id/frendsTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/goodfrendsActivity_frends"
android:textSize="20sp"
android:textColor="#000"
android:textStyle="bold"
       />

<ImageView
   android:id="@+id/frendsArrow"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="center"      
   android:src="@drawable/icon_msgarrow"
   android:contentDescription="@string/contnetdescription"
   />
</LinearLayout>

<RelativeLayout
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical" 
   android:background="@drawable/bg_activitycontent"
   >

<!-- 微博内容部分 -->
<ListView
   android:id="@+id/frendslistView"
   android:layout_width="match_parent" 
   android:layout_height="wrap_content"
   android:background="#BBFFFFFF"
   android:divider="#f1f2f2"
        android:dividerHeight="1dp"
   android:cacheColorHint="#000000"
   android:fastScrollEnabled="true"
   android:focusable="true"       
   ></ListView>        
</RelativeLayout>  


</LinearLayout>


package com.czu.sinaweibo;



import java.io.IOException;
import java.net.MalformedURLException;
import java.util.List;


import com.czu.constdata.ConstDataSinaAPI;
import com.czu.sinaweibo.R;
import com.czu.utils.Global;
import com.czu.weiboHandler.WeiBoInfoPraser;
import com.czu.weiboadapter.FrendsAdapter;
import com.czu.weiboadapter.FrendsInfo;
import com.weibo.net.WeiboException;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;




public class GoodFrendsActivity extends Activity {


/* goodfrendsActivity的标题内容 */
private TextView titleTextView = null;


/* 显示微博信息的列表 */
private ListView frendsListView = null;


/* 对话框 */
// private ProgressDialog progressDialog = null;


@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.goodfrends_activity);


frendsListView = (ListView) this.findViewById(R.id.frendslistView);


titleTextView = (TextView) this.findViewById(R.id.frendsTextView);




setListViewContent(ConstDataSinaAPI.friends);


LinearLayout layout = (LinearLayout) this
.findViewById(R.id.frendsTitle);


layout.setOnClickListener(new OnClickListener() {


@Override
public void onClick(View v) {
if (titleTextView.getText().toString().equals("全部关注")) {
/* 得到我的粉丝列表 */
setListViewContent(ConstDataSinaAPI.followers);
/* 设置当前标题为粉丝 */
titleTextView
.setText(R.string.goodfrendsActivity_followers);


} else {
/* 得到所有我关注的人 */
setListViewContent(ConstDataSinaAPI.friends);
/* 设置当前标题为@我的评论 */
titleTextView.setText(R.string.goodfrendsActivity_frends);
}


}
});


}


private void setListViewContent(String urlPath) {


WeiBoInfoPraser informationParser = new WeiBoInfoPraser(this);
List<FrendsInfo> frendsInfos = null;
try {


frendsInfos = informationParser.getFrendsInfos(urlPath, Global
.getCurrentUserInfo().getUserId());


/* 新建一个FrendsInfoAdapter */
FrendsAdapter frendsAdapter = new FrendsAdapter(this, frendsInfos,
urlPath);


frendsListView.setAdapter(frendsAdapter);


// frendsListView.setOnItemClickListener(new OnItemClickListener() {
//
// @Override
// public void onItemClick(AdapterView<?> adapter, View view,
// int position, long id) {
//
//
// }
//
// });


} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WeiboException e) {
e.printStackTrace();
}


}


}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值