0

私は expandablelistview を使用しました。用語のリストとその説明がありますが、用語をクリックすると何度も説明が表示されます.写真が添付されているので、私の意味を理解できます..

問題

展開可能なリストビュー アダプターのクラスは

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;
}

}

そして主な活動はこれ

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;
}

 }
4

2 に答える 2

0
Try using  item.setText(termDetail.get(groupPosition));
于 2013-09-07T12:27:04.963 に答える