Android, How to split ListView items into three parts?
ANDROID : split the screen in 2 equals parts with 2 listviews
http://codetheory.in/android-dividing-listview-sections-group-headers/
但问题是我使用自定义适配器和Holder类进行列表视图,因此无法维护状态。
任何有任何建议或有用的链接来解决我的问题。
这是我的代码:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
ViewHolder holder;
if (null == view ) {
view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.custom_list_item_one_on_one, parent, false);
holder = new ViewHolder();
holder.seprater = (TextView) view.findViewById(R.id.separator);
holder.avatar = (RoundedImageView) view.findViewById(R.id.imageViewUserAvatar);
holder.userName = (TextView) view.findViewById(R.id.textviewUserName);
holder.userStatus = (TextView) view.findViewById(R.id.textviewUserStatus);
holder.statusImage = (ImageView) view.findViewById(R.id.imageViewStatusIcon);
holder.unreadCount = (TextView) view.findViewById(R.id.textviewSingleChatUnreadCount);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
Buddy buddy = getItem(position);
Log.i("YES-1.0@!", buddy.separator + " / " + buddy.id + " / " + SECTIONED_LOCAL_BUDDID);
if (SECTIONED_LOCAL_BUDDID == 0L)
SECTIONED_LOCAL_BUDDID = buddy.id;
if (buddy.separator.trim().equals("Local") && SECTIONED_STATE_LOCAL) {
holder.seprater.setVisibility(View.VISIBLE);
holder.seprater.setText("Local");
SECTIONED_STATE_LOCAL = false;
} else if (buddy.separator.trim().equals("International") && SECTIONED_STATE_INTERNATIONAL){
holder.seprater.setText("International");
holder.seprater.setVisibility(View.VISIBLE);
SECTIONED_STATE_INTERNATIONAL = false;
}