다른 목록 카테고리를 구분하는 목록과 헤더를 표시하는 AdapterView
이 있습니다. 이 목록은 사용자 입력이있는 SQLite 데이터베이스로 채워집니다. 지금까지 모든 것이 효과적입니다.getView가 뷰 매개 변수를 반환하지 않음
헤더 카테고리에 항목이없는 경우 헤더를 제거하고 싶습니다.
public View getView(int position, View convertView, ViewGroup parent)
{
int viewType = getItemViewType(position);
if (viewType == TYPE_NORMAL)
{
// If the convertView is a textview (group), ignore it
if (convertView instanceof TextView)
{
convertView = null;
}
final int mapCursorPos = getInteralItemPosition(position);
return super.getView(mapCursorPos, convertView, parent);
}
else
{
// Check if it's a text view
TextView text;
if (convertView == null || !(convertView instanceof TextView))
{
((ListView) parent).setDivider(null);
((ListView) parent).setDividerHeight(0);
text = (TextView) inflater.inflate(R.layout.main_list_group, parent, false);
}
else
{
text = (TextView) convertView;
}
final String group = groupsIndexer.get(position).getName(resources);
//Code to hide menu title.
text.setText(group);
text.setVisibility(View.INVISIBLE);
myCursor = getCursor();
initCols(myCursor);
myCursor.moveToFirst();
while (myCursor.isAfterLast() == false)
{
String groupCursor = getGroup(myCursor).getName(resources);
if (groupCursor == group)
{
text.setHeight(12);
text.setPadding(20, 10, 0, 10);
text.setVisibility(View.VISIBLE);
}
myCursor.moveToNext();
}
return text;
}
}
을 그래서, 당신은 내가 특정 카테고리에있는 항목이 있는지 확인하기 위해 데이터베이스를 쿼리 다음과 같은 눈에 보이지 않는 텍스트를 설정하고 시작하고있을 경우 내가 설정을 볼 수 있습니다 : 코드는 다음과 보이는 것에 대한 가시성.
그러나 반환 할 때 메서드는 while 루프에있는 내용을 무시하는 것으로 보입니다. 각 텍스트 뷰 객체를 getView()
을 통해 개별적으로 형식화 할 수 있습니까?
미리 감사드립니다.