Android Studio:ExpandableListView中的多个Textview和设置值

时间:2016-07-01 14:26:03

标签: android arraylist

我是Android工作室的新手,我正在尝试为我的可扩展列表视图中的4文本视图增加价值。我相信我并没有错过很多编码,因为当我添加-f时。这是我的价值复制4次。

在我的Adapter.java中:

resto.add("something");

在我的mainActiviity.java中:

@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
    if (convertView == null) {
        LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                convertView = infalInflater.inflate(R.layout.item_layout, null);
    }

TextView address = (TextView) convertView.findViewById(R.id.address);
TextView phone = (TextView) convertView.findViewById(R.id.phone);
TextView lunchTime = (TextView) convertView.findViewById(R.id.lunchTime);
TextView lunchDetails = (TextView) convertView.findViewById(R.id.lunchDetails);

String text = (String) getChild(groupPosition, childPosition);

address.setText(text);
lunchTime.setText(text);
lunchDetails.setText(text);

return convertView;
}

谢谢!

0 个答案:

没有答案