android 列表二级显示不出来,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 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:

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical">

android:layout_marginTop="5dp"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_marginLeft="15dp">

android:layout_alignParentLeft="true"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="10dp">

android:id="@+id/tv_poi_f_dialog_team"

android:layout_width="wrap_content"

android:layout_height="wrap_content">

android:id="@+id/tv_poi_f_dialog_number"

android:layout_marginLeft="5dp"

android:layout_width="wrap_content"

android:layout_height="wrap_content">

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">

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="wrap_content">

android:background="#ADADAD"

android:layout_marginTop="5dp"

android:layout_width="fill_parent"

android:layout_height="1dp"/>

poi_f_dialog_person.xml:

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical">

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_marginTop="3dp"

android:orientation="horizontal">

android:id="@+id/iv_poi_f_dialog_header"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="40dp">

android:id="@+id/rl_poi_f_dialog"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="5dp">

android:id="@+id/tv_poi_f_dialog_nick"

android:layout_width="wrap_content"

android:layout_height="wrap_content">

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">

android:background="#ADADAD"

android:layout_marginTop="3dp"

android:layout_width="fill_parent"

android:layout_height="1dp">

poi_f_dialog.xml:

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical">

android:layout_width="fill_parent"

android:layout_height="fill_parent">

android:id="@+id/ll_poi_f_content"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent">

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值