Android Expandablelistview-在子视图中多次获取相同的文本

Android Expandablelistview-在子视图中多次获取相同的文本,android,expandablelistview,Android,Expandablelistview,我使用了expandablelistview,我有一个术语列表和它的解释,但是点击术语我会多次得到解释。。我附上了一张照片,以便你们能理解我的意思 可扩展listview适配器的类为 public class ExpandableAdapter extends BaseExpandableListAdapter { private Activity context; //private Map<String, String> termCollections; private Li

我使用了expandablelistview,我有一个术语列表和它的解释,但是点击术语我会多次得到解释。。我附上了一张照片,以便你们能理解我的意思

可扩展listview适配器的类为

public class ExpandableAdapter extends BaseExpandableListAdapter {

private Activity context;
//private Map<String, String> termCollections;
private List<String> term;
private List<String> termDetail;

public ExpandableAdapter(Activity context,
 List<String> term, List<String> termDetail) {
    Log.i("expandable called","called");
    this.context = context;
    //this.termCollections = termCollections;
    this.term = term;
    this.termDetail=termDetail;
}

@Override
public Object getChild(int groupPosition, int childPosition) {
    return null;
}

@Override
public long getChildId(int groupPosition, int childPosition) {
    return 0;
}

@Override
public View getChildView(final int groupPosition, final int childPosition,
        boolean isLastChild, View convertView, ViewGroup parent) {


     String termTemp = (String) termDetail.get(groupPosition);

     TextView item=null ;

    LayoutInflater inflater = context.getLayoutInflater();

    if (convertView == null) {
        convertView = inflater.inflate(R.layout.child_item, null);
    }

    item = (TextView) convertView.findViewById(R.id.termtv);     

    item.setText(termTemp);
    Log.i("Inside child",""+item.getText());
    return convertView;
}

@Override
public int getChildrenCount(int groupPosition) {
     return termDetail.size();
}

@Override
public Object getGroup(int groupPosition) {
    return term.get(groupPosition);
}

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

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

@Override
    public void onGroupCollapsed(int groupPosition) {
        super.onGroupCollapsed(groupPosition);
    }
 @Override
    public void onGroupExpanded(int groupPosition) {
        super.onGroupExpanded(groupPosition);
    }


@Override
public View getGroupView(int groupPosition, boolean isExpanded,
        View convertView, ViewGroup parent) {
    String laptopName = (String) getGroup(groupPosition);

    if (convertView == null) {
        LayoutInflater infalInflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = infalInflater.inflate(R.layout.group_item,
                null);
    }
    TextView item = (TextView) convertView.findViewById(R.id.group_termtv);
    item.setTypeface(null, Typeface.BOLD);
    item.setText(laptopName);
    return convertView;
}

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

@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
    return false;
}

}
公共类ExpandableAdapter扩展了BaseExpandableListAdapter{
私人活动语境;
//私人地图收藏;
私有列表术语;
私人清单条款详情;
公共可扩展适配器(活动上下文,
列表项,列表项详细信息){
Log.i(“可扩展调用”、“调用”);
this.context=上下文;
//this.termCollections=termCollections;
这个术语=术语;
this.termDetail=termDetail;
}
@凌驾
公共对象getChild(int-groupPosition,int-childPosition){
返回null;
}
@凌驾
公共长getChildId(int-groupPosition,int-childPosition){
返回0;
}
@凌驾
公共视图getChildView(最终int groupPosition,最终int childPosition,
布尔值isLastChild、视图转换视图、视图组父级){
字符串termTemp=(字符串)termDetail.get(groupPosition);
TextView项=null;
LayoutInflater充气器=上下文。getLayoutInflater();
if(convertView==null){
convertView=充气机。充气(R.layout.child_项,空);
}
item=(TextView)convertView.findViewById(R.id.termtv);
项setText(术语温度);
Log.i(“内部子对象”,“item.getText());
返回视图;
}
@凌驾
公共整数getChildrenCount(整数组位置){
返回termDetail.size();
}
@凌驾
公共对象getGroup(int-groupPosition){
返回条件.get(groupPosition);
}
@凌驾
public int getGroupCount(){
返回项.size();
}
@凌驾
公共长getGroupId(int-groupPosition){
返回组位置;
}
@凌驾
公共void-ongroupposition(int-groupPosition){
super.ongroupposition(groupPosition);
}
@凌驾
已扩展的公共组(int-groupPosition){
super.onGroupExpanded(groupPosition);
}
@凌驾
公共视图getGroupView(int-groupPosition,布尔值isExpanded,
视图(视图、视图组父级){
字符串laptopName=(字符串)getGroup(groupPosition);
if(convertView==null){
LayoutInflater infalInflater=(LayoutInflater)上下文
.getSystemService(上下文布局\充气机\服务);
convertView=充气机充气(R.layout.group_项目,
无效);
}
TextView项=(TextView)convertView.findViewById(R.id.group\u termtv);
item.setTypeface(null,Typeface.BOLD);
item.setText(laptopName);
返回视图;
}
@凌驾
公共布尔表ID(){
返回false;
}
@凌驾
公共布尔值isChildSelectable(int-groupPosition,int-childPosition){
返回false;
}
}
主要的活动是

public class Term extends Activity {
List<String> groupList;
List<String> childList;
Map<String, String> termCollection;
ExpandableListView expListView;
DbHelper db;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_term);
    db = new DbHelper(Term.this);
    createGroupList();

    createChildList();

    expListView = (ExpandableListView) findViewById(R.id.termList);
    final ExpandableAdapter expListAdapter =
   new ExpandableAdapter(this, groupList, childList);
    expListView.setAdapter(expListAdapter);

}


private void createGroupList() {

    groupList=db.getTotalTerm();

}


private void createChildList() {        

    childList= db.getTotalTermDetail();

}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_term, menu);
    return true;
}

 }
公共类术语扩展活动{
列表组列表;
儿童名单;
地图收集;
ExpandableListView解释视图;
dbdb;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u术语);
db=新的DbHelper(术语this);
createGroupList();
createChildList();
expListView=(ExpandableListView)findViewById(R.id.termList);
最终可扩展适配器外植体适配器=
新的可扩展适配器(此、组列表、子列表);
expListView.setAdapter(expListAdapter);
}
私有void createGroupList(){
groupList=db.getToAlterm();
}
私有void createChildList(){
childList=db.getToAltermDetail();
}
@凌驾
公共布尔onCreateOptions菜单(菜单){
//为菜单充气;这会将项目添加到操作栏(如果存在)。
getMenuInflater().充气(R.menu.activity\u术语,菜单);
返回true;
}
}
改为

@Override
public int getChildrenCount(int groupPosition) {
 return 1;
}
@Override
public int getChildrenCount(int groupPosition) {
 return termDetail.size();
}
@Override
public int getChildrenCount(int groupPosition) {
 return 1;
}