// Initialize a TextChatFragment instance and add it to the UI private void loadTextChatFragment() { int containerId = R.id.fragment_textchat_container; mFragmentTransaction = FragmentManager.beginTransaction(); mTextChatFragment = (TextChatFragment)this.FragmentManager.findFragmentByTag("TextChatFragment"); if (mTextChatFragment == null) { mTextChatFragment = new TextChatFragment(); mTextChatFragment.MaxTextLength = 1050; mTextChatFragment.setTextChatListener(this); mTextChatFragment.setSenderInfo(mSession.Connection.ConnectionId, mSession.Connection.Data); mFragmentTransaction.add(containerId, mTextChatFragment, "TextChatFragment").commit(); } }