Fragment 实现底部导航栏的简单切换

2023-05-16

第一个Android App:
一直想入android这个坑,但一直因为各种原因拖到了现在,今天终于下定决心迈出了第一步。由于公司一直没有android的项目。所以也没有现成的设计和切图,这对于一个刚入坑的人来说真的挺痛苦的,后来实在没办法,就想到了我平时看小说的软件。经历各种办法终于从apk中拿到了切图。下面就开始吧,走起!

目标:
这里写图片描述
不要想多,今天只是实现底部导航栏的点击切换。

1. 首先将页面的布局写好,这里不多说了。直接上代码。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <FrameLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >
    </FrameLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:background="@drawable/home_bg_shape" >

        <RelativeLayout
            android:id="@+id/bookshelf_layout"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/home_bookshelf_image"
                    android:layout_width="wrap_content"
                    android:layout_height="30dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/icon_home_tab_bookshelf_n" />

                <TextView
                    android:id="@+id/home_bookshelf_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:text="@string/bookshelf"
                    android:textColor="#82858b" />
            </LinearLayout>
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/searchbook_layout"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/home_searchbook_image"
                    android:layout_width="wrap_content"
                    android:layout_height="30dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/icon_home_tab_searchbook_n" />

                <TextView
                    android:id="@+id/searchbook_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:text="@string/free"
                    android:textColor="#82858b" />
            </LinearLayout>
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/bookstore_layout"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/home_bookstore_image"
                    android:layout_width="wrap_content"
                    android:layout_height="30dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/icon_home_tab_bookstore_n" />

                <TextView
                    android:id="@+id/bookstore_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:text="@string/bookstore"
                    android:textColor="#82858b" />
            </LinearLayout>
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/writer_layout"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/writer_image"
                    android:layout_width="wrap_content"
                    android:layout_height="30dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/icon_home_tab_writer_n" />

                <TextView
                    android:id="@+id/writer_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:text="@string/writer"
                    android:textColor="#82858b" />
            </LinearLayout>
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/me_layout"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/me_image"
                    android:layout_width="wrap_content"
                    android:layout_height="30dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/icon_home_tab_me_n" />

                <TextView
                    android:id="@+id/me_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:text="@string/me"
                    android:textColor="#82858b" />
            </LinearLayout>
        </RelativeLayout>
    </LinearLayout>

</LinearLayout>

我们运行一下:
这里写图片描述

效果已经出来了,下面我们就为每个按钮创建一个对应的Fragment:
先创建5个layout文件

bookshelf_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:padding="10dp"
            android:text="@string/bookshelf"
            android:textSize="20sp" />
    </LinearLayout>

</RelativeLayout>

searchbook_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:padding="10dp"
            android:text="@string/free"
            android:textSize="20sp" />
    </LinearLayout>

</RelativeLayout>

bookstore_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:padding="10dp"
            android:text="@string/bookstore"
            android:textSize="20sp" />
    </LinearLayout>

</RelativeLayout>

writer_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="vertical" >

            <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:padding="10dp"
            android:text="@string/writer"
            android:textSize="20sp" />
    </LinearLayout>

</RelativeLayout>

me_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:padding="10dp"
            android:text="@string/me"
            android:textSize="20sp" />
    </LinearLayout>

</RelativeLayout>

在创建对应的Fragment 类

BookShelfFragment

package com.example.xxxx.anytravel.fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.xxxx.anytravel.R;

public class BookShelfFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View bookshelfLayout = inflater.inflate(R.layout.bookshelf_layout,
                container, false);
        return bookshelfLayout;
    }
}

SearchBookFragment

package com.example.xxxx.anytravel.fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.xxxx.anytravel.R;

public class SearchBookFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View searchBookLayout = inflater.inflate(R.layout.searchbook_layout, container,
                false);
        return searchBookLayout;
    }
}

BooKStoreFragment

package com.example.xxxx.anytravel.fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.xxxx.anytravel.R;

public class BooKStoreFragment extends Fragment {

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View bookstoreLayout = inflater.inflate(R.layout.bookstore_layout,
                container, false);
        return bookstoreLayout;
    }
}

WriteFragment

package com.example.xxxx.anytravel.fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.pengq.anytravel.R;

public class WriteFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View writeLayout = inflater.inflate(R.layout.writer_layout,
                container, false);
        return writeLayout;
    }
}

MeFragment

package com.example.xxxx.anytravel.fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.pengq.anytravel.R;

public class MeFragment extends Fragment {
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            View meLayout = inflater.inflate(R.layout.me_layout,
                    container, false);
            return meLayout;
        }
}

好了,到了这里准备工作已经完成下面只要实现按钮的点击事件并且加载对应的页面即可;

package com.example.xxxx.anytravel.activity;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.pengq.anytravel.R;
import com.example.pengq.anytravel.fragment.BooKStoreFragment;
import com.example.pengq.anytravel.fragment.BookShelfFragment;
import com.example.pengq.anytravel.fragment.MeFragment;
import com.example.pengq.anytravel.fragment.SearchBookFragment;
import com.example.pengq.anytravel.fragment.WriteFragment;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends BaseActivity implements View.OnClickListener {

    private BookShelfFragment bookShelfFragment;
    private BooKStoreFragment booKStoreFragment;
    private SearchBookFragment searchBookFragment;
    private WriteFragment writeFragment;
    private MeFragment meFragment;
    private List<View> bottomTabs;
    private View bookshelfLayout;
    private View searchBookLayout;
    private View bookStoreLayout;
    private View writerLayout;
    private View meLayout;
    private ImageView bookshelfImage;
    private ImageView searchbookImage;
    private ImageView bookstoreImage;
    private ImageView writerImage;
    private ImageView meImage;
    private TextView bookshelfText;
    private TextView searchBookText;
    private TextView bookStoreText;
    private TextView writerText;
    private TextView meText;
    private FragmentManager fragmentManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getSupportActionBar() != null) {
            getSupportActionBar().hide();
        }
        setContentView(R.layout.activity_main);
        initViews();
        fragmentManager = getFragmentManager();
        setSelectTab(0);
    }

    private void initViews() {
        bookshelfLayout = findViewById(R.id.bookshelf_layout);
        searchBookLayout = findViewById(R.id.searchbook_layout);
        bookStoreLayout = findViewById(R.id.bookstore_layout);
        writerLayout = findViewById(R.id.writer_layout);
        meLayout = findViewById(R.id.me_layout);
        bookshelfImage = (ImageView) findViewById(R.id.home_bookshelf_image);
        searchbookImage = (ImageView) findViewById(R.id.home_searchbook_image);
        bookstoreImage = (ImageView) findViewById(R.id.home_bookstore_image);
        writerImage = (ImageView) findViewById(R.id.writer_image);
        meImage = (ImageView) findViewById(R.id.me_image);
        bookshelfText = (TextView) findViewById(R.id.home_bookshelf_text);
        searchBookText = (TextView) findViewById(R.id.searchbook_text);
        bookStoreText = (TextView) findViewById(R.id.bookstore_text);
        writerText = (TextView) findViewById(R.id.writer_text);
        meText = (TextView) findViewById(R.id.me_text);
        bookshelfLayout.setOnClickListener(this);
        searchBookLayout.setOnClickListener(this);
        bookStoreLayout.setOnClickListener(this);
        writerLayout.setOnClickListener(this);
        meLayout.setOnClickListener(this);
        bottomTabs = new ArrayList<>(5);
        bottomTabs.add(bookshelfLayout);
        bottomTabs.add(searchBookLayout);
        bottomTabs.add(bookStoreLayout);
        bottomTabs.add(writerLayout);
        bottomTabs.add(meLayout);
    }

    private void setSelectTab(int index) {
        clearSelection();
        // 开启一个Fragment事务
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        // 先隐藏掉所有的Fragment,以防止有多个Fragment显示在界面上的情况
        hideFragments(transaction);
        switch (index) {
            case 0:
                bookshelfImage.setImageResource(R.drawable.icon_home_tab_bookshelf_p);
                bookshelfText.setTextColor(Color.parseColor("#00c98d"));
                if (bookShelfFragment == null) {
                    bookShelfFragment = new BookShelfFragment();
                    transaction.add(R.id.content, bookShelfFragment);
                } else {
                    transaction.show(bookShelfFragment);
                }
                break;
            case 1:
                searchbookImage.setImageResource(R.drawable.icon_home_tab_searchbook_p);
                searchBookText.setTextColor(Color.parseColor("#00c98d"));
                if (searchBookFragment == null) {
                    searchBookFragment = new SearchBookFragment();
                    transaction.add(R.id.content, searchBookFragment);
                } else {
                    transaction.show(searchBookFragment);
                }
                break;
            case 2:
                bookstoreImage.setImageResource(R.drawable.icon_home_tab_bookstore_p);
                bookStoreText.setTextColor(Color.parseColor("#00c98d"));
                if (booKStoreFragment == null) {
                    booKStoreFragment = new BooKStoreFragment();
                    transaction.add(R.id.content, booKStoreFragment);
                } else {
                    transaction.show(booKStoreFragment);
                }
                break;
            case 3:
                writerImage.setImageResource(R.drawable.icon_home_tab_writer_p);
                writerText.setTextColor(Color.parseColor("#00c98d"));
                if (writeFragment == null) {
                    writeFragment = new WriteFragment();
                    transaction.add(R.id.content, writeFragment);
                } else {
                    transaction.show(writeFragment);
                }
                break;
            case 4:
                meImage.setImageResource(R.drawable.icon_home_tab_me_p);
                meText.setTextColor(Color.parseColor("#00c98d"));
                if (meFragment == null) {
                    meFragment = new MeFragment();
                    transaction.add(R.id.content, meFragment);
                } else {
                    transaction.show(meFragment);
                }
                break;
            default:
                break;
        }
        transaction.commit();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bookshelf_layout:
                setSelectTab(0);
                break;
            case R.id.searchbook_layout:
                setSelectTab(1);
                break;
            case R.id.bookstore_layout:
                setSelectTab(2);
                break;
            case R.id.writer_layout:
                setSelectTab(3);
                break;
            case R.id.me_layout:
                setSelectTab(4);
                break;
            default:
                break;
        }
    }

    private void clearSelection() {
        bookshelfImage.setImageResource(R.drawable.icon_home_tab_bookshelf_n);
        bookshelfText.setTextColor(Color.parseColor("#82858b"));
        searchbookImage.setImageResource(R.drawable.icon_home_tab_searchbook_n);
        searchBookText.setTextColor(Color.parseColor("#82858b"));
        bookstoreImage.setImageResource(R.drawable.icon_home_tab_bookstore_n);
        bookStoreText.setTextColor(Color.parseColor("#82858b"));
        writerImage.setImageResource(R.drawable.icon_home_tab_writer_n);
        writerText.setTextColor(Color.parseColor("#82858b"));
        meImage.setImageResource(R.drawable.icon_home_tab_me_n);
        meText.setTextColor(Color.parseColor("#82858b"));
    }

    private void hideFragments(FragmentTransaction transaction) {
        if (bookShelfFragment != null) {
            transaction.hide(bookShelfFragment);
        }
        if (searchBookFragment != null) {
            transaction.hide(searchBookFragment);
        }
        if (booKStoreFragment != null) {
            transaction.hide(booKStoreFragment);
        }
        if (writeFragment != null) {
            transaction.hide(writeFragment);
        }
        if (meFragment != null) {
            transaction.hide(meFragment);
        }
    }
}

好,上图(原谅我不会动图)
这里写图片描述

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Fragment 实现底部导航栏的简单切换 的相关文章

  • 数论----质数的求解(C/C++)

    CSDN的uu xff0c 你们好呀 xff0c 今天我们要学习的内容是 数论 哦 xff01 这也是算法题中的一类题目吧 记好安全带 xff0c 准备发车咯 xff01 x1f680 学习数论的意义 x1f4e2 算法导论说 xff1a
  • 源代码是指什么?

    源代码是指以特定编程语言编写的文本文件 xff0c 用于控制软件 硬件 计算机程序或系统 源代码是代表软件不同功能的一类 指令 下面我将详细说明源代码的定义 首先要说的是 xff0c 源代码是建立在编程语言之上的文本文件 它可用于编写程序
  • Java 中如何优化大量的 if...else...

    策略模式 xff08 Strategy Pattern xff09 将每个条件分支的实现作为一个独立的策略类 xff0c 然后使用一个上下文对象来选择要执行的策略 这种方法可以将大量的if else语句转换为对象之间的交互 xff0c 从而
  • Selenium+Pytest自动化测试框架实战,还不会点这里一清二楚,全网最细教程!

    如果下方文字内容没有看明白的话 xff0c 我推荐大家看一套视频 xff0c 比文字内容讲的更加详细 xff01 在华为工作了10年的大佬出的Web自动化测试教程 xff0c 华为现用技术教程 xff01 哔哩哔哩 bilibili 在华为
  • node(编写结构化程序)

    node js的使用 console log 39 小邹最黑 39 使用js文件 去执行NodeJS代码 掌握 1 在代码文件夹中 新建js文件 不要新建成html 里面写任意js代码 const skill 61 39 喵喵拳 39 co
  • ubuntu操作系统查看已安装的包

    dpkg的介绍 dpkg 是 Debian Packager 的简写 为 Debian 专门开发的套件管理系统 xff0c 方便软件的安装 更新及移除 所有源自 Debian 的 Linux 发行版都使用 dpkg xff0c 例如 Ubu
  • Java多线程开发之~~~多条件Condition接口的使用

    我们在多线程开发中 xff0c 可能会出现这种情况 就是一个线程需要另外一个线程满足某某条件才能继续运行 xff0c 或者需 要其他线程满足好几个条件才能运行 xff0c 对于这样的多条件的多线程并发 xff0c 我们如何控制好各个线程之间
  • 如何获取某一天股票数据接口

    怎么样去获取某一天的股票数据接口 xff0c 是需要讲究一定技术的 xff0c 首先是要求想要获取的人是否具备编程技术 xff0c 会不会使用编程语言 xff0c 比如Python C 43 43 Java等等 还有就是从证券机构上获取 x
  • Matlab数字图像处理 编写一个基于GUI的图像处理程序/软件,功能按钮和界面布局自己设定,遵循美观大方、方便操作的原则

    Matlab数字图像处理 压缩包包含 m和 fig文件以及文档 xff0c 具体实现标准参照以下要求 xff1a 第一部分 xff1a 编写一个基于GUI的图像处理程序 软件 xff0c 功能按钮和界面布局自己设定 xff0c 遵循美观大方
  • 多线程的理解

    多线程的作用和简介 xff1a 1 同时完成几项互不干扰的工作 xff0c 提高CPU使用率 比如高速的四车道和八车道 2 多线程就好比在等待水开的同时看报纸 xff0c 而不是等水开了之后再看报纸 xff0c 多线程是为了同步完成多项任务
  • 普通类和抽象类的区别和联系

    包含抽象方法的类称为抽象类 xff0c 但并不意味着抽象类中只能有抽象方法 xff0c 它和普通类一样 xff0c 同样可以拥有成员变量和普通的成员方法 注意 xff0c 抽象类和普通类的主要有三点区别 xff1a 1 抽象方法必须为pub
  • Ubuntu 运行 sh 脚本报错syntax error near unexpected token `(‘

    今天下午疯狂copy张院士的代码 xff0c 对COG进行批处理 xff0c 由于是自己的第一次尝试 xff0c 直接在windows系统下 txt输出代码改 sh后缀 xff0c 直接拷贝到ubuntu系统中运行 xff0c 出现了标题中
  • 蚁群算法(路径规划)

    蚁群算法是根据蚂蚁寻找取得食物的最短路径的原理实现的路径规划算法 蚂蚁在寻找食物时 xff0c 根据路径的长短来释放信息素 xff0c 越短的路径上信息素越多 久而久之 xff0c 后来的蚂蚁根据信息素的指引都会走向这条最优路径 一般来说我
  • 新手Github的打开及使用(托管代码);Git与小乌龟的安装;从0到1教程

    1 Github因网络问题无法打开的解决方案 2 Github用户注册 3 创建远程仓库 4 Git与小乌龟的安装 5 克隆远程到本地 6 上传本地至远程仓库 1 Github因网络问题无法打开的解决方案 因为Github的服务器在国外 x
  • github个人博客快速搭建教程

    文章目录 首先搭建起一个github博客1 左上角标题及简介以及下方的介绍2 评论和访客数3 文章4 Home Archives Categories 和 Tags5 Collections6 Demo7 About 首先搭建起一个gith
  • linux内核设计与实现

    一 linux内核简介 1 linux简介 1 1 unix的特点 unix很简洁 xff0c 仅提供几百个系统调用 xff0c 并有非常明确的设计目的 unix所有东西都当作文件对待 xff0c 这种抽象使对数据和设备都通过一套相同的系统
  • SSH命令

    概念 安全外壳协议 xff08 Secure Shell Protocol xff0c 简称SSH xff09 是一种加密的网络传输协议 xff0c 可在不安全的网络中为网络服务提供安全的传输环境 SSH通过在网络中建立安全隧道 xff08
  • freemarker.template.TemplateNotFoundException: Template not found for name "*.ftl"

    Freemarker 加载模板方法 xff08 SpringBoot环境 xff09 最近项目上用到freeMarker 的模板 xff0c 遇到有关配置freeMarker的模板路径时 xff0c 配置过如下情况 xff1a span c
  • Python中的类属性和实例属性及对其的访问

    类属性和实例属性的说明 实例对象 通过类创建的对象 类属性 类对象所拥有的属性 实例属性 实例对象所特有的属性 xff0c 类对象不能拥有 xff0c 不能通过类对象来调用 它可以放在构造方法 init 中 xff0c 也可以在创建实例对象
  • Ubuntu18.04中解决ROS系统出现sudo rosdep init和rosdep update失败的方法(实测很有用!)

    1 输入 sudo rosdep init 出现 sudo xff1a rosdep command not found的问题 解决方法 xff1a 安装相应的包 sudo apt get install python rosdep 2 输

随机推荐