- I am getting json from php server.
- Depending upon the json I have to populate my listview.
- I have 2 section in my listview (Local users and International users)
- I have gone through following links to solve my issue:
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/
But the problem is I am using Custom Adapter with the Holder class for list view so it is unable to maintain it states.
anyone any suggestion or useful links to solve my issue.
here is my code:
@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;
}