Hi in the below code how to find the last position of the friends[position].userName and then how to compare it and based on the position how to set the text for holder.text1.
For example friends[position] it reaches the last positions means then upto some position friends[position].userName values are there.Now next position I want to occupy this holder.text1.setText(groupdetails); value
Can any one help me
java
public class FriendList extends ListActivity
{
private static final int ADD_NEW_FRIEND_ID = Menu.FIRST;
private static final int CREATE_GROUP_ID = Menu.FIRST+1;
private static final int EXIT_APP_ID = Menu.FIRST + 2;
private IAppManager imService = null;
private FriendListAdapter friendAdapter;
String groupdetails;
public String ownusername = new String();
private class FriendListAdapter extends BaseAdapter
{
class ViewHolder {
TextView text,text1;
ImageView icon;
}
private LayoutInflater mInflater;
private Bitmap mOnlineIcon;
private Bitmap mOfflineIcon;
private FriendInfo[] friends = null;
public FriendListAdapter(Context context) {
super();
mInflater = LayoutInflater.from(context);
mOnlineIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.greenstar);
mOfflineIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.redstar);
}
public void setFriendList(FriendInfo[] friends)
{
this.friends = friends;
}
public int getCount() {
return friends.length;
}
public FriendInfo getItem(int position) {
return friends[position];
}
public long getItemId(int position) {
return 0;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null)
{
convertView = mInflater.inflate(R.layout.friend_list_screen,null);
holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.text);
holder.text1 = (TextView) convertView.findViewById(R.id.text1);
holder.icon = (ImageView) convertView.findViewById(R.id.icon);
convertView.setTag(holder);
}
else {
holder = (ViewHolder) convertView.getTag();
}
holder.text.setText(friends[position].userName);
if((friends[position]).userName.length()>18)
{
holder.text1.setVisibility(View.VISIBLE);
holder.text1.setText(groupdetails);
}
holder.icon.setImageBitmap(friends[position].status == STATUS.ONLINE ? mOnlineIcon : mOfflineIcon);
return convertView;
}
}