设为首页 加入收藏

TOP

Android Studio 使用ViewPager + Fragment实现滑动菜单Tab效果 --简易版(三)
2019-09-01 23:15:03 】 浏览:82
Tags:Android Studio 使用 ViewPager Fragment 实现 滑动 菜单 Tab 效果 简易
lse
if (position == 1) { 132 item_category_report.setTextColor(Color.parseColor("#1ba0e1")); 133 item_detail.setTextColor(Color.parseColor("#000000")); 134 } 135 } 136 } View Code

 

        需要多少个Fragment,便创建多少个,这里只举例写一个,其它相同

        建立Fragment(fragment_one.xml):

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent">
 5 
 6     <TextView
 7         android:layout_width="wrap_content"
 8         android:layout_height="wrap_content"
 9         android:layout_gravity="center"
10         android:text="@string/detail_tab"
11         android:textSize="25sp"/>
12 
13 </LinearLayout>
View Code

 

        Fragment界面代码(OneFragment.java):

 1 package com.hyl.acccountbookdemo;
 2 
 3 import android.os.Bundle;
 4 import android.support.v4.app.Fragment;
 5 import android.view.LayoutInflater;
 6 import android.view.View;
 7 import android.view.ViewGroup;
 8 
 9 /**
10  * @programName: OneFragment.java
11  * @programFunction:
12  * @createDate: 2018/09/25
13  * @author: AnneHan
14  * @version:
15  * xx.   yyyy/mm/dd   ver    author    comments
16  * 01.   2018/09/25   1.00   AnneHan   New Create
17  */
18 public class OneFragment extends Fragment {
19     @Override
20     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
21         // Inflate the layout for this fragment
22         return inflater.inflate(R.layout.fragment_one, container, false);
23     }
24 }
View Code

 

        strings.xml:

<string name="detail_tab">明细</string>
<string name="category_report_tab">类别报表</string>

 

        colors.xml:

<color name="main_tab_text_color">#000000</color>

 

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Android系统修改之Notification布.. 下一篇Flutter 不一样的跨平台解决方案

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目