Skip to main content

Add friend page

The add friend page lets users search for and add new friends by entering a unique identifier. The page consists of the following components:

  • AddFriendListActivity: Container that loads and displays AddFriendListFragment.
  • AddFriendListFragment: Core UI component that displays the search box, hint text, and handles user input and search operations.
  • AddFriendListViewModel: Manages data and business logic, searches for friends based on user input, and passes results to AddFriendListFragment.
  • XML layout: nc_page_friend_list_add.xml
Add friend page

Launch the add friend page

Java
startActivity(AddFriendListActivity.newIntent(getContext()));

Customize the add friend page

To customize the add friend page, extend AddFriendListFragment. For more information about custom fragments, see Page customization design.

Java
// Custom AddFriendListFragment
public class CustomAddFriendListFragment extends AddFriendListFragment {

@Override
protected void onViewReady(@NonNull AddFriendListViewModel viewModel) {
super.onViewReady(viewModel);
// Change the title text
headComponent.setTitleText("New Title");

// Override the back button click event
headComponent.setLeftClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

}
});

// Override search behavior
searchComponent.setSearchQueryListener(
new SearchComponent.OnSearchQueryListener() {
@Override
public void onSearch(String query) {
// Handle search input
}

@Override
public void onClickSearch(String query) {
// Handle search button click
}
});
}

// Override search result navigation
@Override
protected void onUserProfileSearchResult(UserProfile userProfiles) {

}
}