0
확장 가능한 목록을 표시하는 응용 프로그램을 만들고 있습니다. 사실 개체에는 어떤 자식도 없을 때가 있습니다. 그래서 내 확장 목록에 자식 요소가있는 요소 만 표시하고 싶습니다. 확장형 목록보기 android
public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) {
// Check if the object as child
System.out.println("Result list :: " + mParent.get(i).getListe());
if(mParent.get(i).getListe().isEmpty()){
return null;
}
if (view == null) {
view = inflater.inflate(R.layout.list_item_parent, viewGroup,false);
}
TextView textView = (TextView) view.findViewById(R.id.list_item_text_view);
//"i" is the position of the parent/group in the list
textView.setText(getGroup(i).toString());
// Set the Image View with the brand logo
ImageView logo = (ImageView) view.findViewById(R.id.brandlogo);
// Set image Source
logo.setImageResource(mParent.get(i).getLogoPath());
// Set Image size
logo.getLayoutParams().height = 42;
logo.getLayoutParams().width = 226;
//return the entire view
return view;
}
거기인가 : 내가 getGroupView의 함수 내 경우를 넣어 시도하고 객체가 자식이없는 경우, 내가 null을 반환하지만 NullPointerException이 오류가 ... 여기
는 기능입니다 방법이 기능을 건너 뛸까요?
getGroupCount()
함수에서
'올바른보기로 돌아 가기'란 무엇을 의미합니까? –
해당 위치에있는 자식이있는보기 – JafarKhQ
하지만 그룹이없는 경우 어떤 자식으로 반환합니까? –