我有一个聊天应用程序,我正在寻找一种方法来隐藏聊天的个人资料图像,当同一个人有两个或更多连续聊天时,我该怎么办?或者可能使用不同的聊天泡泡,如Facebook或其他聊天应用
以下是我所拥有的样本,
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 :(得分: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();
}