2021-10-09

西门子V90 PN伺服控制核心:FB284功能块详解与实战 在工业自动化中,伺服定位控制是运动控制的基础环节,其本质是PLC通过PROFINET协议与伺服驱动器实现高速、确定性数据交互。FB284作为西门子为V90 PN定制的标准化功能块,封装了GSD映射、状态机管理与周期性PDO同步机制,将底层寄存器操作抽象为高可靠调用接口。相比MOVE指令或MC_MoveAbsolute等通用方案,FB284显著降低时序错乱风险,提升多轴同步精度与故障响应能力。它广泛应用于包装、灌装、装配等中端产线,尤其适配S7-1200/1500平台下的快速部署与现场维护。本文聚焦V90 P 阅读详情

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


一、实验内容

实现APP门户界面框架设计,至少包含4个tab页,能实现tab页之间的点击切换。

1.效果图

在这里插入图片描述

2.工程目录结构

工程结构

二、核心技术

使用布局(layout)和分段(fragment),对控件进行点击监听。

三、实验步骤

主要的实验步骤如下

1.Top界面


布局文件(top.xml)

在这里插入图片描述

设计界面

在这里插入图片描述

2.Button界面


控件关系

在这里插入图片描述

资源图片

在这里插入图片描述
图片来源阿里巴巴矢量库

布局文件(button.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="65dp"

        android:baselineAligned="false"
        android:orientation="horizontal"
        app:layout_constraintBottom_toBottomOf="parent">

        <LinearLayout
            android:id="@+id/linearlayout_1"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/imageView_1"
                android:layout_width="wrap_content"
                android:layout_height="45dp"
                android:contentDescription="@string/app_wechat"
                app:srcCompat="@drawable/wechat" />

            <TextView
                android:id="@+id/textView_1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:text="@string/app_wechat"

                android:textSize="15sp" />

        </LinearLayout>

        <LinearLayout
            android:id="@+id/linearlayout_2"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/imageView_2"
                android:layout_width="wrap_content"
                android:layout_height="45dp"
                android:contentDescription="@string/app_address"
                app:srcCompat="@drawable/addr" />

            <TextView
                android:id="@+id/textView_2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="@string/app_address"
                android:textSize="15sp" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/linearlayout_3"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/imageView_3"
                android:layout_width="wrap_content"
                android:layout_height="45dp"
                android:contentDescription="@string/app_find"
                app:srcCompat="@drawable/find" />

            <TextView
                android:id="@+id/textView_3"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="@string/app_find"
                android:textSize="15sp" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/linearlayout_4"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/imageView_4"
                android:layout_width="wrap_content"
                android:layout_height="45dp"
                android:contentDescription="@string/app_me"
                app:srcCompat="@drawable/me" />

            <TextView
                android:id="@+id/textView_4"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="@string/app_me"
                android:textSize="15sp" />
        </LinearLayout>
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>



设计界面

在这里插入图片描述

3.activity_main界面


布局文件

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    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"
    tools:context=".MainActivity">

    <include
        layout="@layout/top"
        app:layout_constraintTop_toTopOf="@+id/fl_content" />

    <FrameLayout
        android:id="@+id/fl_content"
        android:layout_marginTop="55dp"
        android:layout_marginBottom="65dp"
        android:background="#f0f0f0"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        />

    <include layout="@layout/button"/>

</androidx.constraintlayout.widget.ConstraintLayout>

设计界面

在这里插入图片描述

控件关系

在这里插入图片描述

4.Fragment部分


需要的类:

在这里插入图片描述

布局文件目录:

在这里插入图片描述
在类简单的重写onCreateView()方法,其他方法可以按需重写!
(如下,其余三个文件改写方法相同)

package com.firsttest.myapplication;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.fragment.app.Fragment;

public class addrFragment extends Fragment {

    private View view;
    private String content;

    public addrFragment(String content){
        this.content=content;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view=inflater.inflate(R.layout.fragment_addr,container,false);
        TextView textView=(TextView)view.findViewById(R.id.textView_addr);
        textView.setText(content);
        return view;
    }
}


布局文件:

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

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/textView_wechat"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:textSize="24sp"
            android:text="@string/wechatPrint" />
    </RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

设计界面(之一)

在这里插入图片描述

5.编写MainActivity.java


package com.firsttest.myapplication;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.os.Bundle;
import android.view.SurfaceControl;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import static com.firsttest.myapplication.R.id.imageView_1;
import static com.firsttest.myapplication.R.id.imageView_2;
import static com.firsttest.myapplication.R.id.imageView_3;
import static com.firsttest.myapplication.R.id.imageView_4;
import static com.firsttest.myapplication.R.id.textView_1;
import static com.firsttest.myapplication.R.id.textView_2;
import static com.firsttest.myapplication.R.id.textView_3;
import static com.firsttest.myapplication.R.id.textView_4;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private LinearLayout ll_1;
    private LinearLayout ll_2;
    private LinearLayout ll_3;
    private LinearLayout ll_4;

    private TextView tv_1;
    private TextView tv_2;
    private TextView tv_3;
    private TextView tv_4;

    private ImageView iv_1;
    private ImageView iv_2;
    private ImageView iv_3;
    private ImageView iv_4;

    private TextView txt_setting;
    private FrameLayout fl_content;

    private wechatFragment fg1;
    private addrFragment fg2;
    private findFragment fg3;
    private meFragment fg4;

    private FragmentManager fManager;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        fManager=getSupportFragmentManager();
        bindViews();
        ll_1.performClick();
    }
//事件绑定
    private void bindViews() {
        tv_1=(TextView) findViewById(textView_1);
        tv_2=(TextView)findViewById(textView_2);
        tv_3=(TextView)findViewById(textView_3);
        tv_4=(TextView)findViewById(textView_4);

        iv_1=(ImageView)findViewById(imageView_1);
        iv_2=(ImageView)findViewById(imageView_2);
        iv_3=(ImageView)findViewById(imageView_3);
        iv_4=(ImageView)findViewById(imageView_4);


        ll_1=(LinearLayout)findViewById(R.id.linearlayout_1);
        ll_2=(LinearLayout)findViewById(R.id.linearlayout_2);
        ll_3=(LinearLayout)findViewById(R.id.linearlayout_3);
        ll_4=(LinearLayout)findViewById(R.id.linearlayout_4);

        fl_content=(FrameLayout)findViewById(R.id.fl_content);

        ll_1.setOnClickListener(this);//点击事件绑定
        ll_2.setOnClickListener(this);
        ll_3.setOnClickListener(this);
        ll_4.setOnClickListener(this);



    }

    //重置选中状态
    private void setSelected(){
        ll_1.setSelected(false);
        ll_2.setSelected(false);
        ll_3.setSelected(false);
        ll_4.setSelected(false);
    }

    private void hideAllFragment(FragmentTransaction fragmentTransaction){
        if(fg1!=null)fragmentTransaction.hide(fg1);
        if(fg2!=null)fragmentTransaction.hide(fg2);
        if(fg3!=null)fragmentTransaction.hide(fg3);
        if(fg4!=null)fragmentTransaction.hide(fg4);
    }


//重置颜色,没有选中就为灰色
    private void turnColorToGray(){
        tv_1.setTextColor(0xd0d0d0d0);//灰色
        tv_2.setTextColor(0xd0d0d0d0);
        tv_3.setTextColor(0xd0d0d0d0);
        tv_4.setTextColor(0xd0d0d0d0);
       iv_1.setImageResource(R.drawable.wechat_);//替换为灰色的图片
       iv_2.setImageResource(R.drawable.addr_);
       iv_3.setImageResource(R.drawable.find_);
       iv_4.setImageResource(R.drawable.me_);
    }

    @Override
    public void onClick(View view) {
        FragmentTransaction fTransaction=fManager.beginTransaction();
        hideAllFragment(fTransaction);turnColorToGray();
        switch(view.getId()){
            case R.id.linearlayout_1:
                setSelected();
                tv_1.setTextColor(0xff1B940A);iv_1.setImageResource(R.drawable.wechat);
               //选中就着色
                ll_1.setSelected(true);
                if(fg1==null) {
                    fg1 = new wechatFragment("这是微信界面");
                    fTransaction.add(R.id.fl_content,fg1);
                }
                else{
                    fTransaction.show(fg1);
                }
                break;
            case R.id.linearlayout_2:
                setSelected();
                tv_2.setTextColor(0xff1B940A);iv_2.setImageResource(R.drawable.addr);
                ll_2.setSelected(true);
                if(fg2==null) {
                    fg2 = new addrFragment("这是通讯录界面");
                    fTransaction.add(R.id.fl_content,fg2);
                }
                else{
                    fTransaction.show(fg2);
                }break;
            case R.id.linearlayout_3:
                setSelected();
                tv_3.setTextColor(0xff1B940A);iv_3.setImageResource(R.drawable.find);
                ll_3.setSelected(true);
                if(fg3==null) {
                    fg3 = new findFragment("这是发现页");
                    fTransaction.add(R.id.fl_content,fg3);
                }
                else{
                    fTransaction.show(fg3);
                }break;
            case R.id.linearlayout_4:
                setSelected();
                tv_4.setTextColor(0xff1B940A);iv_4.setImageResource(R.drawable.me);
                ll_4.setSelected(true);
                if(fg4==null) {
                    fg4 = new meFragment("这是个人页");
                    fTransaction.add(R.id.fl_content,fg4);
                }
                else{
                    fTransaction.show(fg4);
                }break;
        }
        fTransaction.commit();
    }
}

四、运行结果

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

五、仓库地址

gitee

ArcGIS新手必看:5分钟搞定等高线转DEM栅格(附完整操作截图) 本文详细介绍了在ArcGIS中将等高线转换为DEM栅格的完整流程,包括CAD数据预处理、TIN转栅格和直接插值法两种核心方法,以及常见问题排查与优化技巧。通过实战案例和操作截图,帮助GIS新手快速掌握这一测绘数据处理的核心技能,提升地形分析和三维可视化效率。 阅读详情

相关推荐

3D Slicer的学习(二) 图像的分割

先对不同层级标注,然后点击Fill between slices -> Initialize -> Apply拖动层级颜色区域就会变成连续自适应的动态变化区域。如图,点击Level tracing,在图像上放置鼠标,会显示可能想要选中区域的轮廓,点击鼠标右键会将其显示为蓝色。然后点击Grow from seeds -> Initialize -> Apply,显示3D之后会自动扩展到其他位置的相同部位,从而展示整个部位。如图为copy之后,将黄色区域的颜色复制到原本的绿色区域。

tuweibazong的博客 6090

时间类型转换的问题“2021-01-20T10:09:11Z”

关于新手碰到时间类型转换的问题: 拿到的时间为字符串,格式为:“2021-01-20T10:09:11Z”。 容易理解的解决方法: 先将该字符串转换为Date类型: SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd’T’HH:mm:ss’Z’”); Date applyDate = sdf.parse(“2021-01-20T10:09:11Z”); 再将Date类型转换为需要的字符串类型: SimpleDateFormat sdf1 = new

JavaWHD的博客 6623

整理并记录几种运算放大器

运算放大器是一种十分常见的电子元器件,最近我在学习运放,以前在学校没有好好的学习,今天在B站看了唐老师讲运算放大器-唐老师讲电赛系列视频教程,记录下所学的,纯当是自己的笔记 学习运放,有两个重要的概念及重要的计算法宝,虚短vp=vn;和虚断ip=in 1反向比例运算电路 Rf可以大于、小于或等于R,起到放大、跟随、衰减输入的作用; 平衡电阻没有太高的精度要求,可加可不加; 有些运放内部集成了补偿电路,就不需要使用平衡电阻,加了反而增大误差,如OPA227 2.同向比例运放电路 .

qq_36823004的博客 6373

2021_10_09aa1234

jdidirktkfklgtltkktkt

qq_62762429的博客 85

UniApp实战:从文件下载到本地保存与预览的一站式解决方案

本文深入解析了UniApp开发中文件下载、保存与预览的完整流程,提供了基于uni.downloadFile、uni.saveFile和uni.openDocument API的一站式实战解决方案。文章详细拆解了核心API的使用方法、多平台(App、H5)的兼容性处理、常见坑点(如文件路径、权限、格式支持)以及进阶优化技巧(如进度提示、文件管理),旨在帮助开发者构建健壮、用户体验良好的跨平台文件处理功能。

d3e4f的博客 618

解决linux 2.5G网卡驱动问题

解决linux 2.5G网卡驱动问题 关键词:2.5G网卡驱动,ubuntu,安装,2.5G Ethernet LINUX driver,Realtek网卡驱动 由于2.5G网卡较新,各linux发行版的通用驱动已不适用,新装的系统会出现无法上网问题,由于国内网络环境去Realtek官网很难下载到驱动文件,故本文提供github上的2.5G Ethernet LINUX driver r8125 for kernel up to 5.6的版本驱动文件r8125-9.003.05.tar.bz2各位可以自

poorguy_aos的博客 1万+

2021-09-10

立项申请 查询范围 => rules => EndBack => update 交换1和27图片 项目经费 流程跟踪 弃项(管理,学生,教师)、恢复 其他申请页面(暂不修改) Oracle中查看所有表和字段以及表注释、字段注释 https://www.cnblogs.com/xusir/p/3214714.html dubbo配置,wpy Flowable基础表 https://blog.csdn.net/z491036107/article/details/104014..

li_dian_jin的博客 152

Windows 10/11一键搞定HDF5文件查看:HDFView 3.4.1免配置安装指南(附中文路径避坑技巧)

本文详细介绍了HDFView 3.4.1在Windows 10/11上的免配置安装方法及中文路径优化技巧。作为HDF5文件查看的专业工具,HDFView 3.4.1简化了安装流程,提升了科研数据处理效率,特别适合遥感、气象等领域的研究人员使用。

qsc9012345的博客 1151
上一篇: c#实现记事本
下一篇: recycleview添加item点击事件--作业三
Ryan415
博客等级 码龄6年 0粉丝 9原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值