[android] 练习viewpagerindicator的使用(一)
主要是学习一下使用这个库
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eee"
android:orientation="vertical" >
<include layout="@layout/main_head"/>
<com.viewpagerindicator.TabPageIndicator
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/vpi_tab"
android:background="#C0D0E0">
</com.viewpagerindicator.TabPageIndicator>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/vp_content"/>
</LinearLayout>
MainActivity.java
package com.example.csdn; import com.viewpagerindicator.TabPageIndicator; import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager; public class MainActivity extends FragmentActivity {
private TabPageIndicator tpi_tab;
private ViewPager vp_content; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tpi_tab = (TabPageIndicator) findViewById(R.id.vpi_tab);
vp_content = (ViewPager) findViewById(R.id.vp_content);
FragmentManager fm = getSupportFragmentManager();
TabAdapter adapter = new TabAdapter(fm);
// ViewPager设置适配器
vp_content.setAdapter(adapter);
// 指示器绑定ViewPager
tpi_tab.setViewPager(vp_content, 0);
} } /**
* 适配器
*
* @author taoshihan
*
*/
class TabAdapter extends FragmentPagerAdapter { public static final String[] TITLES = new String[] { "业界", "移动", "研发" }; public TabAdapter(FragmentManager fm) {
super(fm);
} @Override
public Fragment getItem(int arg0) {
return new Fragment();
} @Override
public int getCount() {
return TITLES.length;
} @Override
public CharSequence getPageTitle(int position) {
// TODO Auto-generated method stub
return TITLES[position % TITLES.length];
}
}
[android] 练习viewpagerindicator的使用(一)的更多相关文章
- Android stuido viewpagerindicator的使用
Top Level Build.gradle buildscript { repositories { maven { url "http://dl.bintray.com/populov/ ...
- [android] 练习viewpagerindicator的使用(二)
主要还是想实现滑动的tab切换效果 MainActivity.java package com.example.csdn; import com.viewpagerindicator.TabPageI ...
- Android 中ViewPagerIndicator的使用
1.https://github.com/JakeWharton/Android-ViewPagerIndicator 2.http://blog.csdn.net/xiaanming/article ...
- 59.Android开源项目及库 (转)
转载 : https://github.com/Tim9Liu9/TimLiu-Android?hmsr=toutiao.io&utm_medium=toutiao.io&utm_so ...
- ViewPagerindicator 源码解析
ViewPagerindicator 源码解析 1. 功能介绍 1.1 ViewPagerIndicator ViewPagerIndicator用于各种基于AndroidSupportL ...
- Android开源项目及库搜集
TimLiu-Android 自己总结的Android开源项目及库. github排名 https://github.com/trending,github搜索:https://github.com/ ...
- 各种Android UI开源框架 开源库
各种Android UI开源框架 开源库 转 https://blog.csdn.net/zhangdi_gdk2016/article/details/84643668 自己总结的Android开源 ...
- 组件--Fragment(碎片)第二篇详解
感觉之前看的还是不清楚,重新再研究了一次 Fragment常用的三个类: android.app.Fragment 主要用于定义Fragment android.app.FragmentManager ...
- 全局对象Application的使用,以及如何在任何地方得到Application全局对象
Application和Activity,Service一样是android框架的一个系统组件,当android程序启动时系统会创建一个application对象,用来存储系统的一些信息.通常我们是不 ...
随机推荐
- Postman使用手册3——环境变量
一.环境变量 当使用API的时候,你可能经常需要使用不同的设置.环境设置可以让你使用变量自定义request.这个方法可以让你轻松的在不同的设置之间改变而不用改变你的request.你不需要担心要记住 ...
- 博弈论教程(A Course in Game Theory)摘录
P4 在我们所研究的模型中,决策主体往往要在不确定条件下进行决策.参与人可能: 不能确定环境的客观因素: 对博弈中发生的事件不很清楚: 不能确定别的不确定参与人的行动: 不能确定别的参与人的推理. 为 ...
- Navigator导航器
import React, { Component } from 'react';import { Platform, StyleSheet, Text, View, Navigator, Touch ...
- php中慎用==
var_dump(' 123fg456'==123);var_dump('some string' == 0);var_dump(123.0 == '123d456');var_dump(0 == & ...
- js对函数参数的封装
对函数参数的封装 一个原始函数有n个参数,用wrap对函数进行封装,生成一个新的函数,当给它传入参数数量为n的时候,将执行原始函数,否则不执行 //函数封装 function wrap(func){ ...
- MySQL数据库 053
mysql 使用: 开启服务端软件 mysqld 开启客户端软件 mysql -uroot -p mysql : 就是一个基于socket编写的c/s架构的软件 概念介绍 : 数据库服务器 : 运行数 ...
- Oracle触发器简单使用记录
在ORACLE系统里,触发器类似函数和过程.1.触发器类型:(一般为:语句级触发器和行级触发器.) 1).DML触发器: 创建在表上,由DML事件引发 2).instead of触发器: 创建在视图上 ...
- Removable Storage Devices文件夹删除方法
Windows10的桌面上出现了名为“Removable Storage Devices”的文件夹删除方法 比较莫名奇妙,突然桌面上出现了名为“Removable Storage Devices”的文 ...
- Docker - 故障排查指南
这阵子开始捣鼓 Docker,遇到过不少问题,下面记录下问题以及解决方案 一.Docker 报 Failed to start Docker Application Container Engine ...
- Binder 驱动(三)
Binder 驱动是 Binder 的最终实现, ServiceManager 和 Client/Service 进程间通信最终都是由 Binder 驱动投递的. Binder 驱动的代码位于 ker ...