android 新手引导轮播,开源中国系列三:一行代码实现资讯页面轮播图

自定义控件

联网

工具

数据库

源码分析相关面试题

Activity相关面试题

Service相关面试题

与XMPP相关面试题

与性能优化相关面试题

与登录相关面试题

与开发相关面试题

与人事相关面试题

AAffA0nNPuCLAAAAAElFTkSuQmCC

使用步骤

1. 在project的build.gradle添加如下代码(如下图)allprojects {

repositories {

...

maven { url "https://jitpack.io" }

}

}

AAffA0nNPuCLAAAAAElFTkSuQmCC

jitpack.png

2. 在Module的build.gradle添加依赖compile 'com.github.open-android:LoopViewPager:1.0.0'

3. 复制如下代码到xml

android:id="@+id/lvp_pager"

android:layout_width="match_parent"

android:layout_height="200dp"

app:animStyle="accordion"

app:animTime="1000"

app:loopTime="3000">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_gravity="bottom"

android:background="#55000000"

android:gravity="center"

android:orientation="horizontal"

android:padding="10dp">

//表示轮播图的文字        

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

android:maxLines="1"

android:textColor="#FF0000"

android:textSize="16sp" />

//表示轮播图的点        

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="10dp"

app:dotShape="oval"

app:dotSize="10dp" />

4. 复制如下代码到Activityprivate void initBanneer() {

Request request = ItheimaHttp.newGetRequest("action/apiv2/banner?   catalog=1");//apiUrl格式:"xxx/xxxxx"

Call call = ItheimaHttp.send(request, new HttpResponseListener() {        @Override

public void onResponse(BannerBean bean, Headers headers) {

List itemDatas = bean.getItemDatas();            for (int i = 0; i 

textLists.add(itemDatas.get(i).name);

imageLists.add(itemDatas.get(i).img);

}

mLoopViewPager.setImgData(imageLists);

mLoopViewPager.setTitleData(textLists);

mLoopViewPager.start();

}

});

}

作者:马伟奇

链接:https://www.jianshu.com/p/ca8991932448

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值