확장 가능한 listview를 만들었습니다. 더하기를 클릭하면 해당 하위 이름과 개수가 movielist에 추가된다는 것을 의미합니다. 중복 된 하위 이름과 개수가 목록에 추가됩니다. 증가 카운트 값과 이름이 list.I에 추가됩니다 관련 name`arraylist android에서 중복을 제거합니다.
@Override
public View getChildView(final int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final Child child = (Child) getChild(groupPosition, childPosition);
final Child modelChild = groups.get(groupPosition).getItems().get(childPosition);
viewHolder.plus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
checkin_layout.setVisibility(View.VISIBLE);
if(modelChild.getCount()>=0) // set your count default 0 when you bind data initially
{
int count = (modelChild.getCount()) + 1;
modelChild.setCount(count);
count1=count1+1;
// int s= Integer.parseInt(itemname.getText().toString());
// Log.d("s--", String.valueOf(s));
// count1=s+count1+1;
itemname.setText(Integer.toString(count1)+"items");
// viewHolder.txtView.setText(Integer.toString(count1)+"items");
Detailpage.item.setText(Integer.toString(count1)+"items");
int total = 50 * child.getcount();
String name = modelChild.getName();
Movie movie = new Movie();
movie.setcheckin_name(name);
movie.setcheckin_count(Integer.toString(total));
movieList.add(movie);
HashSet hs = new HashSet();
hs.addAll(movieList);
movieList.clear();
movieList.addAll(hs);
movieList.add(movie);
}
// set your other items if any like above
groups.get(groupPosition).getItems().set(childPosition, modelChild);
notifyDataSetChanged();
}
});
`
해시 세트를 사용해 보았습니다. 복제 된 이름이 사용 된 후에 추가되었습니다. –
@AbserveTech Dude 전 문제가 있었지만 지난 번 논의한 내용에 대해서는 – Nisarg
관련 코드를 보관하고 @AbserveTech ..를 모두 삭제하십시오! ! –