安卓studio仿qq分组出现一些小问题,救急

我先按照以下链接https://www.cnblogs.com/CCCrunner/p/11781589.html
做了一下,没有导入RoundImageView依赖,报错,然后我去掉了一部分child.xml中设置圆形图片的代码,没有报错,但是运行时,点击下拉菜单显示项目has stopped。不知原因出在哪里,请各位大佬指教。下面贴上代码。
Adapter做过细微修改,所有文件都没报错。
这是我自己的child.xml
<?xml version="1.0" encoding="utf-8"?>
android:id="@+id/list_friend"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
    android:id="@+id/iv"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:orientation="vertical">

    <TextView
        android:id="@+id/friendname"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="好友1"
        android:textColor="#000000"
        android:textSize="30dp" />

    <TextView
        android:id="@+id/motto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="这是好友1的签名"
        android:textColor="#000000"
        android:textSize="20dp" />

</LinearLayout>


这是网上的child.xml
<?xml version="1.0" encoding="utf-8"?>
android:id="@+id/list_friend"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.makeramen.roundedimageview.RoundedImageView xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/iv"
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:gravity="center_horizontal"
    android:src="#000000"
    app:riv_border_color="#333333"
    app:riv_border_width="3dip"
    app:riv_corner_radius="10dip"
    app:riv_mutate_background="true"
    app:riv_oval="true" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:layout_toRightOf="@id/iv"
    android:orientation="vertical">

    <TextView
        android:id="@+id/friendname"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="好友1"
        android:textColor="#000000"
        android:textSize="30dp" />

    <TextView
        android:id="@+id/motto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="这是好友1的签名"
        android:textColor="#000000"
        android:textSize="20dp" />

</LinearLayout>


这是我的Adapter.class,与网上的一样,细微处做了修改,不报错
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.test6.R;

import java.util.ArrayList;

public class MyBaseExpandableListAdapter extends BaseExpandableListAdapter {

private ArrayList<Group> gData; //分组
private  ArrayList<ArrayList<Item>> iData; //长链表
private Context mContext;

public MyBaseExpandableListAdapter(ArrayList<Group> gData, ArrayList<ArrayList<Item>> iData, Context mContext) {
    this.gData = gData;
    this.iData = iData;
    this.mContext = mContext;
}

@Override
public int getGroupCount() {
    return gData.size();
}

@Override
public int getChildrenCount(int i) {
    return iData.get(i).size();
}

@Override
public Object getGroup(int i) {
    return gData.get(i);
}

@Override
public Object getChild(int i, int i1) {
    return iData.get(i).get(i1);
}

@Override
public long getGroupId(int i) {
    return i;
}

@Override
public long getChildId(int i, int i1) {
    return i1;
}

@Override
public boolean hasStableIds() {
    return false;
}

/**
 * 取得用于显示给定分组的视图,这个方法仅返回分组的试图对象
 * @param i
 * @param b
 * @param view
 * @param viewGroup
 * @return
 */
@Override
public View getGroupView(final int i, boolean b, View view, final ViewGroup viewGroup) {
    final ViewHolderGroup groupHolder;
    if (view == null){
        view = LayoutInflater.from(mContext).inflate(R.layout.item_group,viewGroup,false);
        groupHolder = new ViewHolderGroup();
        groupHolder.mGroupImage = view.findViewById(R.id.triangle_right);
        groupHolder.mGroupName = view.findViewById(R.id.headtext);
        groupHolder.mGroupNum = view.findViewById(R.id.online_people_num);
        view.setTag(groupHolder);
    }else{
        groupHolder = (ViewHolderGroup) view.getTag();
    }
    //groupHolder.mGroupImage.setImageResource(gData.get(i).getmGroupImage());
    Log.d("gData",gData.get(i).getmGroupImage()+"");
    Log.d("gData",gData.get(i).getmGroupName()+"");
    groupHolder.mGroupName.setText(gData.get(i).getmGroupName());
    groupHolder.mGroupNum.setText(gData.get(i).getmGroupNum());

    return view;
}

@Override
public View getChildView(int i, int i1, boolean b, View view, ViewGroup viewGroup) {
    ViewHolderItem itemHolder;
    if (view == null){
        view = LayoutInflater.from(mContext).inflate(R.layout.item_child,viewGroup,false);
        itemHolder = new ViewHolderItem();
        itemHolder.mPhoto = view.findViewById(R.id.iv);
        itemHolder.mMotto = view.findViewById(R.id.motto);
        itemHolder.mName = view.findViewById(R.id.friendname);
        view.setTag(itemHolder);
    }else{
        itemHolder = (ViewHolderItem) view.getTag();
    }

    itemHolder.mPhoto.setImageResource(iData.get(i).get(i1).getmPhoto());
    itemHolder.mName.setText(iData.get(i).get(i1).getmName());
    itemHolder.mMotto.setText(iData.get(i).get(i1).getmMotto());
    return view;
}

/**
 * 设置子列表是否可以选中
 * @param i
 * @param i1
 * @return
 */
@Override
public boolean isChildSelectable(int i, int i1) {
    return true;
}

private static class  ViewHolderGroup{
    private ImageView mGroupImage;
    private TextView mGroupName; //分组名
    private TextView mGroupNum; //分组人数
    private boolean isDown;

    public ViewHolderGroup() {
        isDown = false;
    }
}
private  static class ViewHolderItem{
    private TextView mName;//人名
    private TextView mMotto; //签名
    private ImageView mPhoto; //头像
}

}

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问