栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

微信简单界面

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

微信简单界面

这里写目录标题
  • 一.top和bottom
    • 1.top
    • 2.bottom
  • 二.创建四个Fragment,分别对应“聊天”、“联系人”、“朋友圈”、“我的”这四个xml文件
  • 三.最后效果图:
  • 四.我的gitee库: [https://gitee.com/jiang-zhongwen/jiang-zhongwen](https://gitee.com/jiang-zhongwen/jiang-zhongwen/).

一.top和bottom 1.top

需要一个linearlayout和一个text View

2.bottom

需要的控件以及呈现效果如下图所示:

这里给出一个LineaLayout示例代码:

 


        

        

    
二.创建四个Fragment,分别对应“聊天”、“联系人”、“朋友圈”、“我的”这四个xml文件

其中wexinFragment函数如下:

 
package com.example.wechat;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


public class wexinFragment extends Fragment {


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_wexin, container, false);
    }
}

各个java文件及Fragment文件如下:

以下是mainactivity函数,具体的函数定义见最后面的链接

 
public class MainActivity extends AppCompatActivity  {
    private Fragment wexinFragment=new wexinFragment();
    private Fragment myFragment=new myFragment();
    private Fragment worldFragment=new worldFragment();
    private Fragment friendFragment=new friendFragment();
    private FragmentManager fm;
    private LinearLayout linearLayout1,linearLayout2,linearLayout3,linearLayout4;
    private TextView textView1,textView2,textView3,textView4;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
        linearLayout1 = findViewById(R.id.LinearLayout_wexin);
        linearLayout2 = findViewById(R.id.LinearLayout_friend);
        linearLayout3 = findViewById(R.id.LinearLayout_world);
        linearLayout4 = findViewById(R.id.LinearLayout_my);
        linearLayout1.setOnClickListener(this::onClick);
        linearLayout2.setOnClickListener(this::onClick);
        linearLayout3.setOnClickListener(this::onClick);
        linearLayout4.setOnClickListener(this::onClick);
        initFragment();
        showfragment(0);
    }
三.最后效果图:

四.我的gitee库: https://gitee.com/jiang-zhongwen/jiang-zhongwen.
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/301247.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号