自定义控件
联网
工具
数据库
源码分析相关面试题
Activity相关面试题
Service相关面试题
与XMPP相关面试题
与性能优化相关面试题
与登录相关面试题
与开发相关面试题
与人事相关面试题
使用步骤
1. 在project的build.gradle添加如下代码(如下图)allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
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