[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对象,用来存储系统的一些信息.通常我们是不 ...
随机推荐
- django admin的自定制
from django.contrib import admin # Register your models here. from .models import * from django.util ...
- OCP 12c最新考试原题及答案(071-8)
8.(5-4) choose the best answer:You need to produce a report where each customer's credit limit has b ...
- MVC软件设计模式
Model(模型):负责数据维护 View(视图):负责向用户呈现数据 Control(控制):负责模型和视图之间的交互 应用:Struts就是基于MVC模式的架构
- 2016级算法第二次上机-G.ModricWang's Real QuickSort
873 思路 这是一道非常基础的题,目的是帮助大家回顾快排相关的知识.大家完成此题之后应该就对快排有比较深刻的印象了. 对于整个快排的流程,题目描述中已经给了清晰完整的伪代码.需要自己加工的部分就是, ...
- Oracle 第三方管理工具整理
Oracle 第三方管理工具整理 1.OB(SI Object Browser) 官方网址: http://www.ctdw.com.cn说明:小软件大功能,个人最爱它的数据库导入.导出功能,一键导入 ...
- [HDU4035] Maze(概率DP)
HDU4035 有\(n\)个房间 , 由\(n-1\)条隧道连通起来 , 实际上就形成了一棵树 , 从结点\(1\)出发 , 开始走 , 在每个结点\(i\)都有\(3\)种可能 : \(1.\)被 ...
- Linux之shell
shell的中文意思是外壳. 通常在图形界面中对实际体验带来的差异不是不同发行版本的终端模拟器,而是shell这个壳. 壳在核外,shell里面的核就是linux内核. shell指的是:提供给使用者 ...
- CentOS7 firewalld打开关闭防火墙 开放端口
firewalld的基本使用 启动: systemctl start firewalld 关闭: systemctl stop firewalld 查看状态: systemctl status fir ...
- PyCharm 通过Github和Git上管理代码
1.最近希望通过github来管理代码,记录下pycharm上的设置,以下是针对windows版本.mac版本略有却别 如图所示 file-settings-Version Control-GitHu ...
- c# 引用类型对象的深拷贝
c#中的对象大体分为值类型和引用类型,值类型大致包括 int, struct等,引用类型大致包括 自定义Class,object 等.string属于特殊的引用类型,不在本文的讨论之内. 值类型直接存 ...