国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Android Studio 制作微信界面 下

這篇具有很好參考價值的文章主要介紹了Android Studio 制作微信界面 下。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

主界面

? ? ?上一篇文章的鏈接:

Android Studio 制作微信界面 上_nazonomaster的博客-CSDN博客https://blog.csdn.net/nazonomaster/article/details/124456716

????????接下來創(chuàng)建fragment的Java文件

????????????????首先是WeixinFragment.java

????????????????在包內(nèi)創(chuàng)建一個名為fragment的文件夾,在該文件夾中創(chuàng)建新的Java類并命名為WeixinFragment

public class WeixinFragment extends Fragment {
    private List<Weixin> weiList = new ArrayList<>();
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.weixin_fragment,container,false);
    }
        @Override
        public void onActivityCreated(@Nullable Bundle savedInstanceState) {
            super.onActivityCreated(savedInstanceState);
            inints();

            WeixinAdapter adapter = new WeixinAdapter(this.getContext(),R.layout.weixin_content_item,
                    weiList);
            ListView listView = getView().findViewById(R.id.weixin_listview);
            listView.setAdapter(adapter);

            listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    Weixin weixin = weiList.get(position);
                    if (weixin.getName()=="笨笨"){
                        Intent intent = new Intent(getActivity(), ChatActivity.class);
                        startActivity(intent);
                    }else {
                        Toast.makeText(getActivity(),"不是通訊錄里的聯(lián)系人( ′_ゝ`)", Toast.LENGTH_SHORT).show();
                    }
                }
            });


        }

    private void inints() {
        for (int i=0; i<2;i++){
            Weixin w1 = new Weixin();
            w1.setImageId(R.mipmap.dingyuehao);
            w1.setName("訂閱號服務(wù)");
            w1.setNeirong("重慶科技學(xué)院:今晚,重科人用歌聲獻(xiàn)禮建黨100周年!");
            weiList.add(w1);

            Weixin w2 = new Weixin();
            w2.setImageId(R.mipmap.yundong);
            w2.setName("運(yùn)動健康");
            w2.setNeirong("[應(yīng)用消息]");
            weiList.add(w2);

            Weixin w3 = new Weixin();
            w3.setImageId(R.mipmap.weixinzhifu);
            w3.setName("微信支付");
            w3.setNeirong("微信支付憑證");
            weiList.add(w3);

            Weixin w4 = new Weixin();
            w4.setImageId(R.mipmap.jizhangben);
            w4.setName("微信記賬本");
            w4.setNeirong("昨日記賬日報(bào),點(diǎn)擊查看詳情");
            weiList.add(w4);

            Weixin w5 = new Weixin();
            w5.setImageId(R.mipmap.youxiang);
            w5.setName("QQ郵箱提醒");
            w5.setNeirong("Nintendo (Hongkong) Limited:最后召集! ...");
            weiList.add(w5);

            Weixin w6 = new Weixin();
            w6.setImageId(R.mipmap.haer);
            w6.setName("笨笨");
            w6.setNeirong("long may the sunshine!");
            weiList.add(w6);
        }

    }
}

????????????????第二個是TongxunluFragment.java

????????????????在fragment文件夾中創(chuàng)建新的Java類并命名為TongxunluFragment

public class TongxunluFragment extends Fragment {
    private List<Tongxunlu> tongxunluList = new ArrayList<>();

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.tongxunlu_fragment,container,false);
    }

    @Override

        public void onActivityCreated(@Nullable Bundle savedInstanceState) {
            super.onActivityCreated(savedInstanceState);
            inints();

            TongxunluAdapter adapter = new TongxunluAdapter(this.getContext(),R.layout.txl_content_item,
                    tongxunluList);
            ListView listView = getView().findViewById(R.id.txl_listview);
            listView.setAdapter(adapter);
        }

    private void inints() {
        Tongxunlu t1 = new Tongxunlu();
        t1.setImageId(R.mipmap.newf);
        t1.setName("新的朋友");
        tongxunluList.add(t1);

        Tongxunlu t2 = new Tongxunlu();
        t2.setImageId(R.mipmap.qunchat);
        t2.setName("群聊");
        tongxunluList.add(t2);

        Tongxunlu t3 = new Tongxunlu();
        t3.setImageId(R.mipmap.biaoqian);
        t3.setName("標(biāo)簽");
        tongxunluList.add(t3);

        Tongxunlu t4 = new Tongxunlu();
        t4.setImageId(R.mipmap.gongzhonghao);
        t4.setName("公眾號");
        tongxunluList.add(t4);

        for (int i=0;i<2;i++){
            Tongxunlu t5 = new Tongxunlu();
            t5.setImageId(R.mipmap.t_tx01);
            t5.setName("笨笨");
            tongxunluList.add(t5);

            Tongxunlu t6 = new Tongxunlu();
            t6.setImageId(R.mipmap.t_tx02);
            t6.setName(" d=( ??。)-好耶");
            tongxunluList.add(t6);

            Tongxunlu t7 = new Tongxunlu();
            t7.setImageId(R.mipmap.t_tx03);
            t7.setName("Hollow Knight");
            tongxunluList.add(t7);

            Tongxunlu t8 = new Tongxunlu();
            t8.setImageId(R.mipmap.t_tx05);
            t8.setName("Mr_Quin");
            tongxunluList.add(t8);

            Tongxunlu t9 = new Tongxunlu();
            t9.setImageId(R.mipmap.t_tx04);
            t9.setName("是acc啦");
            tongxunluList.add(t9);

            Tongxunlu t10 = new Tongxunlu();
            t10.setImageId(R.mipmap.tx_kenny);
            t10.setName("機(jī)智的肯尼");
            tongxunluList.add(t10);
        }


    }

}

????????????????第三個是FaxianFragment.java

????????????????在fragment文件夾中創(chuàng)建新的Java類并命名為FaxianFragment

public class FaxianFragment extends Fragment  {
    private LinearLayout linearLayout;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.faxian_fragment, container, false);

        RelativeLayout relativeLayout = view.findViewById(R.id.pyquan_click);
        relativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(),PyquanActivity.class);
                startActivity(intent);
            }
        });;
        return view;

    }

}

????????????????最后是WodeFragemnt.java

????????????????在fragment文件夾中創(chuàng)建新的Java類并命名為WodeFragemnt?

public class WodeFragemnt extends Fragment {
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.wode_fragment,container,false);
    }
}

????????菜單按鈕布局

????????????????menu_weixin_icon_selector.xml

????????首先是第一個按鈕的布局文件,在main\res\drawable中創(chuàng)建一個新的布局文件并命名為menu_weixin_icon_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@mipmap/faxian02" android:state_pressed="true"/>
    <item android:drawable="@mipmap/faxian02" android:state_selected="true"/>
    <item android:drawable="@mipmap/faxian01"/>
</selector>

????????????????menu_tongxunlu_icon_selector.xml

????????第二個按鈕的布局文件,在main\res\drawable中創(chuàng)建一個新的布局文件并命名為menu_tongxunlu_icon_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@mipmap/tongxunlu02" android:state_pressed="true"/>
    <item android:drawable="@mipmap/tongxunlu02" android:state_selected="true"/>
    <item android:drawable="@mipmap/tongxunlu01"/>
</selector>

????????????????menu_faxian_icon_selector.xml

????????第三個按鈕的布局文件,在main\res\drawable中創(chuàng)建一個新的布局文件并命名為menu_faxian_icon_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@mipmap/faxian02" android:state_pressed="true"/>
    <item android:drawable="@mipmap/faxian02" android:state_selected="true"/>
    <item android:drawable="@mipmap/faxian01"/>
</selector>

????????????????menu_wode_icon_selector.xml

????????第四個按鈕的布局文件,在main\res\drawable中創(chuàng)建一個新的布局文件并命名為menu_wode_icon_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@mipmap/wode02" android:state_pressed="true"/>
    <item android:drawable="@mipmap/wode02" android:state_selected="true"/>
    <item android:drawable="@mipmap/wode01"/>
</selector>

首頁界面

? ? ? ? 布局文件weixin_content_item.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:ignore="MissingDefaultResource">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center"
        android:layout_marginTop="5dp">
        <ImageView
            android:id="@+id/weixin_content_img"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:src="@mipmap/dingyuehao"
            android:layout_marginLeft="10dp"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginLeft="10dp"
            android:orientation="vertical">
            <TextView
                android:id="@+id/weixin_content_txt1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="訂閱號消息"
                android:textSize="24sp"
                android:textColor="#000000"
                />
            <TextView
                android:id="@+id/weixin_content_txt2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="重慶科技學(xué)院:今晚,重科人用歌聲獻(xiàn)..."
                android:textSize="15sp"
                />
            <View
                android:layout_width="match_parent"
                android:layout_height="2dp"
                android:background="#d8dde1"
                android:layout_marginTop="10dp"
                android:layout_marginRight="10dp"/>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

????????Weixin.java

????????在包內(nèi)創(chuàng)建一個新的文件夾entity,在該文件夾中創(chuàng)建新的Java類,命名為Weixin

public class Weixin {
    private String name;
    private String neirong;
    private int imageId;

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public String getNeirong() {
        return neirong;
    }
    public void setNeirong(String neirong) {
        this.neirong = neirong;
    }

    public int getImageId() {
        return imageId;
    }
    public void setImageId(int imageId) {
        this.imageId = imageId;
    }
}

? ? ? ? ?WeixinAdapter.java

?????????在包內(nèi)創(chuàng)建一個新的文件夾adapter,在該文件夾中創(chuàng)建新的Java類,命名為WeixinAdapter

public class WeixinAdapter extends ArrayAdapter<Weixin> {
    private int resourceId;
    private static final String TAG = "WeixinAdapter";
    private List<Weixin> list;

    public WeixinAdapter(@NonNull Context context, int resource, @NonNull List<Weixin> objects) {
        super(context, resource, objects);
        resourceId = resource;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent)
    {
        Weixin weixin = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId,
                parent, false);
        ImageView fruitImage = view.findViewById(R.id.weixin_content_img);
        TextView fruitName = view.findViewById(R.id.weixin_content_txt1);
        TextView fruitNr = view.findViewById(R.id.weixin_content_txt2);

        fruitImage.setImageResource(weixin.getImageId());
        fruitName.setText(weixin.getName());
        fruitNr.setText(weixin.getNeirong());
        return view;
    }
}

????????這樣首頁部分就完成了。?

通訊錄界面

? ? ? ? 布局文件txl_content_item.xml

? ? ? ? 在layout文件夾中創(chuàng)建一個名為txl_content_item的布局文件。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <ImageView
            android:id="@+id/t_tx"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@mipmap/newf"
            android:layout_marginTop="5dp"
            android:layout_marginLeft="10dp"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginLeft="10dp">
            <TextView
                android:id="@+id/t_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="新的朋友"
                android:textSize="19dp"
                android:textColor="#000000"
                android:layout_marginTop="10dp"/>
            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginTop="20dp"
                android:background="#e0e0e0"/>

        </LinearLayout>

    </LinearLayout>


</LinearLayout>

? ? ? ? Tongxunlu.java

????????在entity文件夾中創(chuàng)建一個名為Tongxunlu的Java類文件

public class Tongxunlu {
    private String name;
    private int imageId;

    public String getName(){
        return name;
    }
    public void setName(String name){
        this.name = name;
    }

    public int getImageId(){
        return imageId;
    }
    public void setImageId(int imageId) {
        this.imageId = imageId;
    }
}

? ? ? ? TongxunluAdapter.java

????????在adapter文件夾中創(chuàng)建一個名為TongxunluAdapter的Java類文件

public class TongxunluAdapter extends ArrayAdapter<Tongxunlu> {
    private int resourceId;
    private static final String TAG = "TongxunluAdapter";
    private List<Tongxunlu> list;

    public TongxunluAdapter(@NonNull Context context, int resource, @NonNull List<Tongxunlu> objects) {
        super(context, resource, objects);
        resourceId = resource;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent)
    {
        Tongxunlu tongxunlu = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId,
                parent, false);

        ImageView t_tx = view.findViewById(R.id.t_tx);
        TextView t_name = view.findViewById(R.id.t_name);

        t_tx.setImageResource(tongxunlu.getImageId());
        t_name.setText(tongxunlu.getName());

        return view;
    }
}

聊天功能的實(shí)現(xiàn)

? ? ? ? 聊天界面布局activity_chat.xml

????????在layout文件夾中創(chuàng)建一個名為activity_chat的布局文件

<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
    android:orientation="vertical"
    android:background="#d8e0e8"
    tools:context=".ChatActivity">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:background="#f2f2f2">

        <Button
            android:id="@+id/weixin_back"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="12dp"
            android:background="@mipmap/back" />

        <TextView
            android:id="@+id/chat_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="笨笨"
            android:textSize="25dp"
            android:textColor="#000000"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="15dp"/>
        <Button
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@mipmap/ddd"
            android:layout_alignParentRight="true"
            android:layout_marginTop="12dp"
            android:layout_marginRight="10dp"/>

    </RelativeLayout>

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/msg_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:orientation="horizontal"
        android:background="#f2f2f2">
        <Button
            android:id="@+id/yuyin"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@mipmap/yuyin"
            android:layout_marginTop="10dp"
            android:layout_marginLeft="10dp"/>

        <EditText
            android:id="@+id/input_txt"
            android:layout_width="0dp"
            android:layout_height="42dp"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="10dp"
            android:layout_toRightOf="@+id/yuyin"
            android:layout_toLeftOf="@+id/send_emoji"
            android:layout_marginRight="10dp"
            android:background="#ffffff" />
        <Button
            android:id="@+id/send_emoji"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@mipmap/fabiaoqing"
            android:layout_marginTop="10dp"
            android:layout_marginRight="5dp"
            android:layout_toLeftOf="@+id/btn_send"/>
        <Button
            android:id="@+id/btn_send"
            android:layout_width="60dp"
            android:layout_height="40dp"
            android:text="發(fā)送"
            android:textColor="#ffffff"
            android:textSize="20sp"
            android:background="#32dc60"
            android:layout_alignParentRight="true"
            android:layout_marginTop="10dp"
            android:layout_marginRight="10dp"/>

    </RelativeLayout>


</LinearLayout>

????????聊天框的布局msg_item.xml

????????在layout文件夾中創(chuàng)建一個名為msg_item的布局文件

????????代碼中涉及到聊天框的圖片和路徑,圖片文件保存在res/mipmap_hdpi中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="10dp">

    <LinearLayout
        android:id="@+id/left_layout"
        android:layout_gravity="left"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="@mipmap/message_left">

        <TextView
            android:id="@+id/left_msg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_margin="10dp"
            android:textColor="#fff"
            android:text="你好,小明"/>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/right_layout"
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@mipmap/message_right"
        android:layout_gravity="right">

        <TextView
            android:id="@+id/right_msg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_margin="10dp"
            android:text="口口口口"
            />
    </LinearLayout>
</LinearLayout>

????????Msg.java

????????在entity文件夾中創(chuàng)建一個名為Msg的Java類文件

public class Msg {
    public static final int TYPE_RECEIVED = 0;
    public static final int TYPE_SENT = 1;
    // 消息內(nèi)容
    private String content;
    // 消息類型
    private int type;

    public Msg(String content,int type){
        this.content = content;
        this.type = type;
    }

    public int getType(){
        return type;
    }

    public String getContent(){
        return content;
    }

    public void setContent(String content){
        this.content = content;
    }

    public void setType(int type){
        this.type = type;
    }
}

????????MsgAdapter.java

????????在adapter文件夾中創(chuàng)建一個名為MsgAdapter的Java類文件

public class MsgAdapter extends RecyclerView.Adapter<MsgAdapter.ViewHolder> {
    private List<Msg> mMsgList;
    static class ViewHolder extends RecyclerView.ViewHolder{
        LinearLayout leftLayout;
        LinearLayout rightLayout;
        TextView leftMsg;
        TextView rightMsg;
        public ViewHolder(View view){
            super(view);
            leftLayout = (LinearLayout) view.findViewById(R.id.left_layout);
            rightLayout = (LinearLayout) view.findViewById(R.id.right_layout);
            leftMsg = (TextView) view.findViewById(R.id.left_msg);
            rightMsg = (TextView) view.findViewById(R.id.right_msg);
        }
    }

    public MsgAdapter(List<Msg> msgList){
        mMsgList = msgList;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType){
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.msg_item,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder,int position){
        Msg msg = mMsgList.get(position);
        if (msg.getType() == Msg.TYPE_RECEIVED) {
            holder.leftLayout.setVisibility(View.VISIBLE);
            holder.rightLayout.setVisibility(View.GONE);
            holder.leftMsg.setText(msg.getContent());
        }else if (msg.getType() == Msg.TYPE_SENT){
            holder.rightLayout.setVisibility(View.VISIBLE);
            holder.leftLayout.setVisibility(View.GONE);
            holder.rightMsg.setText(msg.getContent());
        }
    }

    @Override
    public int getItemCount() {
        return mMsgList.size();
    }
}

????????ChatActivity.java

????????在包內(nèi)創(chuàng)建一個名為ChatActivity的Java類文件

public class ChatActivity extends AppCompatActivity {
    private Handler mHandler = new Handler();

    private List<Msg> msgList = new ArrayList<>();
    private EditText inputText;
    private Button send;
    private RecyclerView msgRecyclerView;
    private MsgAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chat);

        //設(shè)置返回按鈕
        Button back = (Button) findViewById(R.id.weixin_back) ;
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        //聊天功能
        inintMsgs();
        inputText = (EditText) findViewById(R.id.input_txt);
        send = (Button) findViewById(R.id.btn_send);
        msgRecyclerView = (RecyclerView) findViewById(R.id.msg_recycler_view);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        msgRecyclerView.setLayoutManager(layoutManager);
        adapter = new MsgAdapter(msgList);
        msgRecyclerView.setAdapter(adapter);
        send.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String content = inputText.getText().toString();
                if (!"".equals(content)){
                    Msg msg = new Msg(content,Msg.TYPE_SENT);
                    msgList.add(msg);
                    adapter.notifyItemInserted(msgList.size() - 1);
                    msgRecyclerView.scrollToPosition(msgList.size() - 1);
                    inputText.setText("");
                    recrive();
                }else {
                    Toast.makeText(ChatActivity.this,"請輸入",Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

    private void inintMsgs() {
        Msg msg1 = new Msg("Hello",Msg.TYPE_RECEIVED);
        msgList.add(msg1);
        Msg msg2 = new Msg("Never Mind the Slander and Lies",Msg.TYPE_SENT);
        msgList.add(msg2);
        Msg msg3 = new Msg("long may the sunshine!",Msg.TYPE_RECEIVED);
        msgList.add(msg3);
    }
    private void recrive(){
        Msg msg1 = new Msg("you are dragon,more dragon than me",Msg.TYPE_RECEIVED);
        msgList.add(msg1);
    }
}

朋友圈功能的實(shí)現(xiàn)

????????activity_pyquan.xml

????????在layout文件夾中創(chuàng)建一個名為activity_pyquan的布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#ffffff">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:background="#f2f2f2">

        <Button
            android:id="@+id/pyquan_back"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="12dp"
            android:background="@mipmap/back" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="朋友圈"
            android:textSize="25dp"
            android:textColor="#000000"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="15dp"/>
        <Button
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@mipmap/zhaoxiang"
            android:layout_alignParentRight="true"
            android:layout_marginTop="12dp"
            android:layout_marginRight="10dp"/>
    </RelativeLayout>

    <ListView
        android:id="@+id/pyquan_listview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ffffff"
        android:overScrollMode="never"/>
</LinearLayout>

????????pyquan_content_item.xml

????????在layout文件夾中創(chuàng)建一個名為pyquan_content_item的布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:ignore="MissingDefaultResource">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginBottom="5dp">
        <!--頭像-->
        <ImageView
            android:id="@+id/pyquan_touxiang"
            android:layout_width="60dp"
            android:layout_height="60dp"
            android:background="@mipmap/touxiang"
            android:layout_marginLeft="15dp"
            android:layout_marginTop="15dp"/>
        <!--內(nèi)容-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginLeft="10dp">
            <TextView
                android:id="@+id/pyquan_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="所長的肚子"
                android:textSize="20sp"
                android:textColor="#2999ce"
                android:layout_marginTop="15dp"/>
            <TextView
                android:id="@+id/pyquan_txt"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="所若干黑色和人格拉爾感覺到開發(fā)了的概率較大了開長大ad管理卡帶回來卡迪夫辣豆腐靜安寺電話費(fèi)拉收到貨了咖啡機(jī)阿拉斯加代理費(fèi)"
                android:textSize="17dp"
                android:textColor="#000000"/>
            <ImageView
                android:id="@+id/pyquan_peitu"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/photo"
                android:layout_marginTop="5dp"/>
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp">
                <TextView
                    android:id="@+id/pyquan_time"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="2"
                    android:textColor="#b5b5b5"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_toRightOf="@+id/pyquan_time"
                    android:text="小時前"
                    android:textColor="#b5b5b5"/>
                <ImageView
                    android:layout_width="40dp"
                    android:layout_height="20dp"
                    android:background="@mipmap/dian"
                    android:layout_alignParentRight="true"
                    android:layout_marginRight="10dp"
                    />
            </RelativeLayout>

        </LinearLayout>
    </LinearLayout>
</LinearLayout>

????????Pyquan.java

????????在entity文件夾中創(chuàng)建一個名為Pyquan的Java類文件

public class Pyquan {
    private String name;
    private String txt;
    private String time;
    private int imageId1;
    private int imageId2;

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public String getTxt() {
        return txt;
    }
    public void setTxt(String txt) {
        this.txt = txt;
    }

    public String getTime() {
        return time;
    }
    public void setTime(String time) {
        this.time = time;
    }

    public int getImageId1() {
        return imageId1;
    }
    public void setImageId1(int imageId1) {
        this.imageId1 = imageId1;
    }

    public int getImageId2() {
        return imageId2;
    }
    public void setImageId2(int imageId2) {
        this.imageId2 = imageId2;
    }
}

????????PyquanAdapter.java

????????在adapter文件夾中創(chuàng)建一個名為PyquanAdapter的Java類文件

public class PyquanAdapter extends ArrayAdapter<Pyquan> {
    private int resourceId;
    private static final String TAG = "PyquanAdapter";
    private List<Pyquan> list;

    public PyquanAdapter(@NonNull Context context, int resource, @NonNull List<Pyquan> objects) {
        super(context, resource, objects);
        resourceId = resource;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent)
    {
        Pyquan pyquan = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId,
                parent, false);

        ImageView touxiang = view.findViewById(R.id.pyquan_touxiang);
        TextView mingcheng = view.findViewById(R.id.pyquan_name);
        TextView neirong = view.findViewById(R.id.pyquan_txt);
        TextView time = view.findViewById(R.id.pyquan_time);
        ImageView peitu = view.findViewById(R.id.pyquan_peitu);

        touxiang.setImageResource(pyquan.getImageId1());
        peitu.setImageResource(pyquan.getImageId2());
        mingcheng.setText(pyquan.getName());
        neirong.setText(pyquan.getTxt());
        time.setText(pyquan.getTime());

        return view;
    }
}

????????PyquanActivity.java

????????在包內(nèi)創(chuàng)建一個名為PyquanActivity的Java類文件

public class PyquanActivity extends AppCompatActivity {

    private List<Pyquan> pyquanList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pyquan);

        //設(shè)置back按鈕
        Button back = (Button) findViewById(R.id.pyquan_back) ;
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        inints();

        PyquanAdapter adapter = new PyquanAdapter(getApplicationContext(),R.layout.pyquan_content_item,pyquanList);
        ListView listView = findViewById(R.id.pyquan_listview);
        listView.setAdapter(adapter);
    }

    private void inints() {
        Pyquan p1 = new Pyquan();
        p1.setImageId1(R.mipmap.touxiang);
        p1.setImageId2(R.mipmap.photo);
        p1.setName("所長的肚子");
        p1.setTxt("所長的肚子所長的肚子所長的肚子所長的牛子所長的肚子所長的肚子所長的肚子所長的肚子");
        p1.setTime("2");
        pyquanList.add(p1);

        Pyquan p2 = new Pyquan();
        p2.setImageId1(R.mipmap.t_tx05);
        p2.setImageId2(R.mipmap.py02);
        p2.setName("Mr_Quin");
        p2.setTxt("分享圖片");
        p2.setTime("5");
        pyquanList.add(p2);

        Pyquan p3 = new Pyquan();
        p3.setImageId1(R.mipmap.tx_kenny);
        p3.setImageId2(R.mipmap.py03);
        p3.setName("機(jī)智的肯尼");
        p3.setTxt("9494");
        p3.setTime("6");
        pyquanList.add(p3);

        Pyquan p4 = new Pyquan();
        p4.setImageId1(R.mipmap.t_tx04);
        p4.setImageId2(R.mipmap.py05);
        p4.setName("是acc啦");
        p4.setTxt("歇了");
        p4.setTime("7");
        pyquanList.add(p4);

        Pyquan p5 = new Pyquan();
        p5.setImageId1(R.mipmap.t_tx05);
        p5.setImageId2(R.mipmap.py04);
        p5.setName("Mr_Quin");
        p5.setTxt("都怪小櫻");
        p5.setTime("8");
        pyquanList.add(p5);

        Pyquan p6 = new Pyquan();
        p6.setImageId1(R.mipmap.t_tx01);
        p6.setImageId2(R.mipmap.py06);
        p6.setName("笨笨");
        p6.setTxt("不列顛傳說中的王。也被譽(yù)為騎士王。阿爾托莉雅是幼名,自從當(dāng)上國王之后,就開始被稱為亞瑟王了。在騎士道凋零的時代,手持圣劍,給不列顛帶來了短暫的和平與最后的繁榮。史實(shí)上雖為男性,但在這個世界內(nèi)卻似乎是男裝麗人。");
        p6.setTime("9");
        pyquanList.add(p6);

    }


}

工程文件

????????這是這整個工程的文件,需要的話可以通過積分下載。

用AndroidStudio制作微信的界面-Android文檔類資源-CSDN下載這是一個我用AndroidStudio模仿制作微信界面的工程文件的壓縮包更多下載資源、學(xué)習(xí)資料請?jiān)L問CSDN下載頻道.https://download.csdn.net/download/nazonomaster/85232385

?#############? ? ?2023/7/20更新,優(yōu)化了界面? ?#################

?對應(yīng)的工程文件我也進(jìn)行了更新

Android Studio 制作微信界面 下Android Studio 制作微信界面 下

Android Studio 制作微信界面 下Android Studio 制作微信界面 下文章來源地址http://www.zghlxwxcb.cn/news/detail-486631.html

到了這里,關(guān)于Android Studio 制作微信界面 下的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 藍(lán)牙聊天App設(shè)計(jì)1:Android Studio制作藍(lán)牙聊天通訊軟件(UI界面設(shè)計(jì))

    藍(lán)牙聊天App設(shè)計(jì)1:Android Studio制作藍(lán)牙聊天通訊軟件(UI界面設(shè)計(jì))

    前言:藍(lán)牙聊天App設(shè)計(jì)全部有三篇文章(一、UI界面設(shè)計(jì),二、藍(lán)牙搜索配對連接實(shí)現(xiàn),三、藍(lán)牙連接聊天),這篇文章是一、UI界面設(shè)計(jì) 課程1:Android Studio小白安裝教程,以及第一個Android項(xiàng)目案例“Hello World”的調(diào)試運(yùn)行 課程2:藍(lán)牙聊天App設(shè)計(jì)1:Android Studio制作藍(lán)牙聊天通

    2024年02月02日
    瀏覽(36)
  • UI界面開發(fā)- android studio搭建類微信界面

    UI界面開發(fā)- android studio搭建類微信界面

    目錄 1.實(shí)驗(yàn)?zāi)康?2.開發(fā)過程 一、界面框架設(shè)計(jì)思路 Ⅰ:頂部標(biāo)題區(qū)域top.xml Ⅰ:底部功能選擇區(qū)域botten.xml Ⅲ:中間顯示區(qū)域 ?①:創(chuàng)建不同的Fragment.java及l(fā)ayout ②:activity_main.xml整體框架搭建?編輯 ③:實(shí)現(xiàn)Fragment的隱藏和顯示 ? ? ? ??1.在主函數(shù)中定義控件 ? ? ? ??2.定

    2024年02月06日
    瀏覽(26)
  • Android Studio之搭建微信界面

    Android Studio之搭建微信界面

    目錄 目錄 一、功能需求 二?、頁面布局 一,將所需圖片導(dǎo)入 二,?頂部top.xml設(shè)計(jì) 三,底部buttom1.xml設(shè)計(jì) 四,中間頁面設(shè)計(jì) ?五, 將底部中部以及中部進(jìn)行整合 三、頁面跳轉(zhuǎn)控制? 一,BlankFragment文件 二,MainActivity文件 ?四、在任一tab頁中實(shí)現(xiàn)列表效果 ?一, 添加的Recyc

    2024年02月03日
    瀏覽(22)
  • 安卓開發(fā)   微信ui界面設(shè)計(jì) (Android Studio)

    安卓開發(fā) 微信ui界面設(shè)計(jì) (Android Studio)

    功能: 開發(fā)一個類似微信的主頁面框架,UI布局為上中下結(jié)構(gòu),包含4個tab界面: 開發(fā)技術(shù)為: layout xml、控件、監(jiān)聽,fragment; 設(shè)計(jì)流程: 創(chuàng)建項(xiàng)目 改下項(xiàng)目名,編程語言為java UI界面 UI界面由多個xml組成,頭部標(biāo)題為微信,中間留空白,底部分為四個(微信,聯(lián)系人,發(fā)現(xiàn),

    2024年02月15日
    瀏覽(23)
  • android studio——設(shè)計(jì)簡單微信界面超詳細(xì)教程

    android studio——設(shè)計(jì)簡單微信界面超詳細(xì)教程

    一、作業(yè)目標(biāo) 本次作業(yè)開發(fā)的是微信APP的門戶框架,UI布局為上中下結(jié)構(gòu)。 功能一:用戶可通過點(diǎn)擊底部導(dǎo)航欄切換四個板塊進(jìn)行切換,它們分別是“聊天”、“聯(lián)系人”、“功能”、“我的”,每切換一個界面會有對應(yīng)的文本提示。 功能二:在每一tab頁面實(shí)現(xiàn)列表效果。

    2024年02月04日
    瀏覽(52)
  • Android Studio Kotlin 簡單實(shí)現(xiàn)微信主界面UI

    Android Studio Kotlin 簡單實(shí)現(xiàn)微信主界面UI

    ????????????????????????windows11 ????????????????????????文件版本 2023.2.0.0 ????????????????????????產(chǎn)品版本 2023.2.0.AI-232.10227.8.2321._BUILD_NUMBER_ ? ? ? ? JAVA屬性: ?????????????????????????java version \\\"17.0.10\\\" 2024-01-16 LTS ??????

    2024年04月16日
    瀏覽(23)
  • 【移動開發(fā)學(xué)習(xí)】 Android Studio 編寫一個簡單的微信界面

    【移動開發(fā)學(xué)習(xí)】 Android Studio 編寫一個簡單的微信界面

    Android Studio簡單還原微信ui 目標(biāo) 實(shí)現(xiàn)3-4個tab的切換效果 技術(shù)需求 activity, xml, fragment, recyclerview 成果展示 其中聯(lián)系人界面通過recyclerview實(shí)現(xiàn)了可以滑動列表 ?? ?? ? ? 倉庫地址 https://github.com/SmileEX/wecaht.git 實(shí)現(xiàn)過程 主要ui 第一步我們首先把微信的ui主體做出來,即這三個部分

    2024年02月08日
    瀏覽(103)
  • 【移動開發(fā)學(xué)習(xí)】 Android Studio 編寫一個簡單的微信界面 (2)

    【移動開發(fā)學(xué)習(xí)】 Android Studio 編寫一個簡單的微信界面 (2)

    Android Studio簡單還原微信ui 上一期完成內(nèi)容(前情提要) 上次我們簡單地實(shí)現(xiàn)了微信的幾個初始界面,并且在聯(lián)系人頁面通過recycleview添加了許多的view 目標(biāo) 建立在上次的基礎(chǔ)上,我們來擴(kuò)展聯(lián)系人界面的功能,給每一個view添加一個點(diǎn)擊功能,讓其可以跳轉(zhuǎn)到另一個activity,

    2024年02月05日
    瀏覽(93)
  • Android Studio——實(shí)現(xiàn)登錄界面

    Android Studio——實(shí)現(xiàn)登錄界面 在移動應(yīng)用開發(fā)中,登錄界面是一種常見的設(shè)計(jì)需求。通過使用Android Studio,我們可以輕松實(shí)現(xiàn)一個簡單且美觀的登錄界面。本文將介紹如何使用Android Studio創(chuàng)建一個登錄界面,并提供相應(yīng)的源代碼。 步驟1:創(chuàng)建新項(xiàng)目 首先,打開Android Studio并創(chuàng)

    2024年02月08日
    瀏覽(19)
  • Android Studio歡迎界面和登陸界面的設(shè)計(jì)(小白)

    Android Studio歡迎界面和登陸界面的設(shè)計(jì)(小白)

    ? ? ? ? 最近學(xué)校開設(shè)了Android Studio的開發(fā)課程,跟著書上的例子和小破站的視頻開啟了安卓小白之旅,今天主要整理了一下\\\"歡迎界面\\\"和\\\"登陸界面\\\"的相關(guān)內(nèi)容。 ? ? ? ? 首先新建一個項(xiàng)目,按照自己的需求命名項(xiàng)目 新建一個類,命名為Splash ?歡迎界面的頁面布局 在layout中

    2024年02月10日
    瀏覽(25)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包