android dialog显示二级列表

private Dialog createFriendDialog(Context context){
View view = POIItemActivity.this.getLayoutInflater().inflate(R.layout.poi_f_dialog, null);
inflater = POIItemActivity.this.getLayoutInflater();
fDialog = new AlertDialog.Builder(context);
fDialog.setView(view);
fDialog.setIcon(R.drawable.logo);
fDialog.setTitle("选择好友");

layout = (LinearLayout) view.findViewById(R.id.ll_poi_f_content);
showFriendMes();
fDialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
fDialog.create().dismiss();
}
});
return fDialog.create();
}
显示二级列表的函数:
private void showFriendMes() {

layout.removeAllViews();
List<Team> data = Memory.getFriendData();
synchronized (data) {
for(final Team team : data){
//组视图
LinearLayout teamLayout = (LinearLayout) inflater.inflate(R.layout.poi_f_dialog_team, null);
RelativeLayout itemLayout = (RelativeLayout) teamLayout.getChildAt(0);
//展开/收缩 图标
final ImageView icon = (ImageView) itemLayout.getChildAt(1);
LinearLayout itemTeamLayout = (LinearLayout) itemLayout.getChildAt(0);
//组名
TextView teamName = (TextView) itemTeamLayout.getChildAt(0);
teamName.setText(team.getCategoryName());
//组成员数
TextView teamNumber = (TextView) itemTeamLayout.getChildAt(1);
teamNumber.setText(team.getOnlineCount() + "/" + team.getMemberCount());

teamLayout.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
LinearLayout parent = (LinearLayout) v;
View view = parent.getChildAt(1);
int show = view.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE;
view.setVisibility(show);
icon.setImageResource(show == View.VISIBLE ? R.drawable.scroll_to_previous : R.drawable.scroll_to_next);
team.setStatus(show == View.VISIBLE ? 1 : 0);
}
});
LinearLayout teamItem = (LinearLayout) teamLayout.getChildAt(1);
if(team.getStatus() == 1){
teamItem.setVisibility(View.VISIBLE);
}else{
teamItem.setVisibility(View.GONE);
}
teamItem.removeAllViews();
for(final User user : team.getFriendList()){
//孩子视图
LinearLayout userLayout = (LinearLayout) inflater.inflate(R.layout.poi_f_dialog_person, null);
userLayout.setTag(R.string.poi_friends,user);

LinearLayout ll = (LinearLayout) userLayout.getChildAt(0);
//头像
ImageView ivHeader = (ImageView) ll.findViewById(R.id.iv_poi_f_dialog_header);
ivHeader.setImageResource(ImageUtil.getAvatarId(POIItemActivity.this, user.getPicID(), (byte)user.getStatus()));

RelativeLayout rlLayout = (RelativeLayout) ll.getChildAt(1);
//昵称
TextView tvNick = (TextView) rlLayout.getChildAt(0);
// TextView tvNick = (TextView) rlLayout.findViewById(R.id.tv_poi_f_dialog_nick);
tvNick.setText(StringUtil.getDisplayStatusAndName(user.getStatus(), user.getNickName(), user.getRemarkName()));
//名称
TextView tvName = (TextView) rlLayout.findViewById(R.id.tv_poi_f_dialog_name);
tvName.setText(user.getUserName());

userLayout.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
User selectUser = (User) v.getTag(R.string.poi_friends);
if(selectUser.getStatus() == 0){
Toast.makeText(POIItemActivity.this, "离线状态不能发送", Toast.LENGTH_SHORT).show();
}else{

}
}
});
teamItem.addView(userLayout);

}
layout.addView(teamLayout);
}
}
}

poi_f_dialog_team.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">
<RelativeLayout
android:layout_marginTop="5dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp">
<LinearLayout
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp">
<TextView
android:id="@+id/tv_poi_f_dialog_team"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView
android:id="@+id/tv_poi_f_dialog_number"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
<ImageView
android:id="@+id/iv_poi_f_dialog_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_centerVertical="true"
android:src="@drawable/scroll_to_next"
android:layout_marginTop="5dp">
</ImageView>
</RelativeLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</LinearLayout>
<ImageView
android:background="#ADADAD"
android:layout_marginTop="5dp"
android:layout_width="fill_parent"
android:layout_height="1dp"/>
</LinearLayout>
poi_f_dialog_person.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">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_poi_f_dialog_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp">
</ImageView>
<RelativeLayout
android:id="@+id/rl_poi_f_dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp">
<TextView
android:id="@+id/tv_poi_f_dialog_nick"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView
android:id="@+id/tv_poi_f_dialog_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_poi_f_dialog_nick">
</TextView>
</RelativeLayout>
</LinearLayout>
<View
android:background="#ADADAD"
android:layout_marginTop="3dp"
android:layout_width="fill_parent"
android:layout_height="1dp">
</View>
</LinearLayout>

poi_f_dialog.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">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/ll_poi_f_content"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</LinearLayout>
</ScrollView>
</LinearLayout>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值