2015-04-22 42 views
0

我有一个聊天应用程序,我正在寻找一种方法来隐藏聊天的个人资料图像,当有两个或更多连续的同一人聊天时,如何我这样做?或者如果我理解正确这可以帮助你可能会使用不同的聊天泡像Facebook或其他即时通讯应用程式如何检查CursorAdapter中的前一个记录 - Android

下面是什么,我有一个样品,

private static class ChatCursorAdapter extends CursorAdapter { 

    private ChatCursor chatCursor; 

     public ChatCursorAdapter(Context context, CommentsCursor cursor) { 
      super(context, cursor, 0); 
     chatCursor = cursor; 
     } 

     @Override 
     public View newView(Context context, Cursor cursor, ViewGroup parent) { 

      LayoutInflater inflater = (LayoutInflater) context 
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      return inflater.inflate(R.layout.chat_layout, parent, false); 
     } 


    @Override 
    public void bindView(View view, Context context, Cursor cursor) { 
     ImageView imgView = (ImageView) view.findViewById(R.id.imageView1); 
     Chat chat = chatCursor.getChat(); 
     //If the previous chat was from the same 
     //person set the profile image to invisible 
    } 


} 

回答

0

@Override 
public View newView(View view, Context context, Cursor cursor) { 
    int posBeforeLast = cursor.getCount() - 1; 
     //Also can use to check current position of the cursor 
    int currentPostion= cursor.getPosition(); 
} 
相关问题