0
我目前有:用字母順序創建列表視圖?
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.grid_contact_item, null);
}
BaseContact contact = this.getItem(position);
TextView text = (TextView) convertView.findViewById(R.id.contact_name);
if (contact.getName() != null && !contact.getName().equals("")) {
text.setText(contact.getName());
}
ImageView contactIcon = (ImageView) convertView.findViewById(R.id.contact_image);
if ((contact.getPhotoURI() != null && !contact.getPhotoURI().toString().equals(""))) {
Picasso.with(this.ctx).load(contact.getPhotoURI()).transform(new CircleTransform()).into(
contactIcon);
} else if ((contact.getPhotoURI() == null || contact.getPhotoURI().toString().equals(""))
&& (contact.getPhotoThumbURI() != null && !contact.getPhotoThumbURI().toString()
.equals(
""))) {
Picasso.with(this.ctx).load(contact.getPhotoThumbURI()).transform(new CircleTransform()).into(
contactIcon);
} else {
Picasso.with(this.ctx).load(R.drawable.contact_no_picture).transform(new CircleTransform()).into(
contactIcon);
}
return convertView;
}
我想重複一下人們的應用程序有與此類似:
現在,this判斷。
我可以有一個自定義的視圖專用於該部分,但我不太清楚如何確定一個位置是否是一個部分,如果一個部分是空的,它將如何被省略?
但是,我知道如何將標題置於x位置以顯示新信件的開頭? – JamieB
將字段添加到您的BaseContact類 –
這將如何幫助?我已經知道我想添加的人的名字,我需要知道如何以編程方式決定是否應該添加標題或項目。 – JamieB