CometChat Pro Documentation

You'll find comprehensive guides and documentation to help you start working with CometChat as quickly as possible. Let's jump right in!

UI Screens

UI screens are fragment with all the necessary methods and Listeners required to build a chat application. There are different screens available in UI Kit.

1.CometChatUserListScreen

The CometChatUserListScreen is a fragment with a List of users. The Fragment has all the necessary listeners and methods required to display the user's list.

Usage

In your layout.xml add the following snippet to use the CometChatUserListScreen. Adding the following code snippet will give you a fully working list of users.

XML




<fragment
android:id="@+id/userList"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="screen.CometChatUserListScreen"
/>

Note About setItemClickListener on CometChatUserListScreen

To get click event of the list you must use setItemClickListener. The setItemClickListener has
OnItemClick() on handle single click and OnItemClick to handle long click events.

CometChatUserListScreen.setItemClickListener(new OnItemClickListener<User>() {

            @Override
            public void OnItemClick(User var, int position) {
                
            }

            @Override
            public void OnItemLongClick(User var, int position) {
                super.OnItemLongClick(var, position);
            }
        });

2.CometChatGroupListScreen

The CometChatGroupListScreen is a fragment with a List of groups Fragment has all the necessary listeners and methods required to display the list of groups

Usage

In your layout.xml add the following snippet to use the CometChatGroupListScreen.Adding the following code snippet will give you a full working list of groups.

XML




<fragment
android:id="@+id/groupList"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="screen.CometChatGroupListScreen"
/>

Note About setItemClickListener on CometChatGroupListScreen

To get click event of the list you must use setItemClickListener. The setItemClickListener has
OnItemClick() on handle single click and OnItemClick to handle long click events.

CometChatGroupListScreen.setItemClickListener(new OnItemClickListener<Group>() {
            @Override
            public void OnItemClick(Group var, int position) {

            }

            @Override
            public void OnItemLongClick(Group var, int position) {
                super.OnItemLongClick(var, position);
            }
        });

3.CometChatConversationListScreen

The CometChatConversationListScreen is a fragment with a List of conversation. The Fragment has all the necessary listeners and methods required to display the list of conversations.

Usage

In your layout.xml add the following snippet to use the CometChatConversationListScreen.Adding the following code snippet will give you a fully working list of conversations.

XML




<fragment
android:id="@+id/conversationList"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="screen.CometChatConversationListScreen"
/>

Note About setItemClickListener on CometChatConversationListScreen

To get click event of the list you must use setItemClickListener. The setItemClickListener has
OnItemClick() on handle single click and OnItemClick to handle long click events.

CometChatConversationListScreen.setItemClickListener(new OnItemClickListener<Conversation>() {
            @Override
            public void OnItemClick(Conversation var, int position) {

            }

            @Override
            public void OnItemLongClick(Conversation var, int position) {
                super.OnItemLongClick(var, position);
            }
        });

4.CometChatMessageScreen

CometChatMessageScreen is a fragment that consists of send and received messages. It is capable of sending and receiving different types of messages such as text, image, and documents.

Usage

To use CometChatMessageScreen follow the below code snippets. CometChatMessageScreen is a dynamic so it will require some arguments. Add a FrameLayout in your layout.xml .

XML




<FrameLayout
android:id="@+id/chatFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

In your activity set the required parameter in the following manner.

Bundle bundle = new Bundle();
Fragment chatFragment=new CometChatMessageScreen()
  
bundle.putString(StringContract.IntentStrings.AVATAR,"AvatarUrl");
bundle.putString(StringContract.IntentStrings.NAME, "Name");   
bundle.putString(StringContract.IntentStrings.UID,"UID");
bundle.putString(StringContract.IntentStrings.STATUS,"STATUS");
bundle.putString(StringContract.IntentStrings.TYPE,CometChatConstants.RECEIVER_TYPE_USER);
chatFragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction().replace(R.id.chatFrame,fragment).commit();
Bundle bundle = new Bundle();
Fragment chatFragment=new CometChatMessageScreen()
  
bundle.putString(StringContract.IntentStrings.AVATAR,"GroupIcon");
bundle.putString(StringContract.IntentStrings.NAME, "Name");   
bundle.putString(StringContract.IntentStrings.GUID,"GUID");
bundle.putString(StringContract.IntentStrings.TYPE,CometChatConstants.RECEIVER_TYPE_GROUP);
chatFragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction().replace(R.id.chatFrame,fragment).commit();

5.CometChatUserInfoScreen

CometChatUserInfoScreen is a fragment which provides detail about the currently logged-in user in the CometChat.

Usage

Add the following code in your layout.xml

XML




<fragment
android:id="@+id/userInfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="screen.CometChatUserInfoScreen"
/>

6 CometChatCallListScreen

You can use the CometChatCallList to get a list of all the calls made by the logged-in user to other users and groups.

Usage

Add the following code in your layout.xml

XML




<fragment
android:id="@+id/callListScreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="screen.CometChatCallListScreen"
/>

Updated 6 months ago


UI Screens


UI screens are fragment with all the necessary methods and Listeners required to build a chat application. There are different screens available in UI Kit.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.