zoukankan      html  css  js  c++  java
  • 家庭记账本APP开发准备(二)

    今天学习了选项卡,为记账本的分类做了准备。主登录界面进行了优化,但仍未实现各个组件之间的跳转。

    选项卡

    activity_main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <TabHost 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:id="@android:id/tabhost"
        tools:context=".MainActivity">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <TabWidget
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:id="@android:id/tabs"
    
                ></TabWidget>
            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@android:id/tabcontent"
                ></FrameLayout>
        </LinearLayout>
    
    
    </TabHost>
    

      tab1.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:id="@+id/left"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/bg"/>
    
    </LinearLayout>
    

      tab2.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:id="@+id/right"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/img"/>
    
    </LinearLayout>
    

      MainActivity.java

    package com.example.xuanxiang;
    
    import androidx.appcompat.app.AppCompatActivity;
    
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.widget.TabHost;
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            TabHost tabHost =(TabHost) findViewById(android.R.id.tabhost);
            tabHost.setup();//初始化 添加标签页
            LayoutInflater inflater =LayoutInflater.from(this);
            inflater.inflate(R.layout.tab1,tabHost.getTabContentView());
            inflater.inflate(R.layout.tab2,tabHost.getTabContentView());
            tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("选项一").setContent(R.id.left));
            tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("选项二").setContent(R.id.right));
        }
    }
    

      优化美化后的主界面..........

  • 相关阅读:
    jenkins 使用oclint 扫描 oc 代码
    mac下 jenkins 环境搭建
    jenkins 中 Poll SCM 和 Build periodically 的区别
    表单验证封装,一招学会,永远受用
    浅谈js中的执行环境和执行环境对象
    浅谈php之设计模式基础
    四条地铁线带你通往Ajax的大门
    论js结合数学的应用
    以留言本的开发打开ajax的世界
    初步学习css3之3D动画
  • 原文地址:https://www.cnblogs.com/zzmds/p/12289076.html
Copyright © 2011-2022 走看看