直播系统源码,极光IM简单的聊天界面全手动
直播系统源码,极光IM简单的聊天界面全手动实现的相关代码
界面的XML
以下是Activity的布局文件,消息列表我选择用RecyclerView来实现
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/beijing">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/Title_Height"
android:background="@color/white">
<ImageView
android:id="@+id/jg_details_back"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:paddingLeft="30px"
android:paddingRight="60px"
android:src="@mipmap/back" />
<TextView
android:id="@+id/jg_details_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:textColor="@color/heise"
android:textSize="@dimen/Title_TextSize" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/jg_details_recy"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/fenge" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/white"
android:paddingLeft="30px"
android:paddingRight="30px">
<EditText
android:id="@+id/jg_details_edit"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginBottom="20px"
android:layout_marginTop="20px"
android:layout_weight="1"
android:background="@mipmap/sousuo1"
android:gravity="center_vertical"
android:hint="请输入咨询的问题"
android:imeOptions="actionSend"
android:paddingLeft="20px"
android:paddingRight="20px"
android:paddingTop="10px"
android:paddingBottom="10px"
android:singleLine="true"
android:textColor="@color/huise"
android:textCursorDrawable="@null"
android:textSize="14sp" />
<ImageView
android:id="@+id/jg_details_img"
android:layout_width="80px"
android:layout_marginTop="20px"
android:layout_height="80px"
android:layout_marginLeft="20px"
android:src="@mipmap/send_img" />
</LinearLayout>
</LinearLayout>
控件初始化:
这些代码 放在Activity的onCreate方法中就可以了,
其中涉及到的东西都会在下面讲到
title = findViewById(R.id.jg_details_title);
mEdit = findViewById(R.id.jg_details_edit);
mRecycler = findViewById(R.id.jg_details_recy);
mRecycler.setLayoutManager(new LinearLayoutManager(this));
mAdapter = new JG_details_Adapter(this);
mRecycler.setAdapter(mAdapter);
position = getIntent().getIntExtra("position", 0);
//设置消息接收 监听
GlobalEventListener.setJG(this, false);
//进入会话状态,不接收通知栏
JMessageClient.enterSingleConversation(this.userName);
以上就是直播系统源码,极光IM简单的聊天界面全手动实现的相关代码, 更多内容欢迎关注之后的文章