TabLayout +ViewPager + Fragment : RecyclerView展示网络数据 + webView 显示网页

本博客详细介绍了如何结合TabLayout、ViewPager和Fragment实现页面导航切换。首先,通过TabLayout实现页面间的切换,然后利用ViewPager与Fragment配合,创建两个Fragment。在第一个Fragment中,从指定URL获取网络数据,将title和image字段解析并展示到RecyclerView中。而在第二个Fragment中,使用webView加载并显示百度网页。文章提供了必要的代码实例和依赖添加指南,包括权限设置和自定义Application的使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

题目要求:

1,   (25)    使用TabLayout实现页面的导航切换

2,   (25)    实现ViewPager + Fragment ,切换页面, 2Fragment;

3,   (25)    第一个Fragment,  获取网络数据,展示到RecyclerView

地址:  http://app.vmoiver.com/apiv3/post/getPostInCate?cateid=0&p=1

解析字段:  title ,  image

4,   (25)    第二个Fragment, 通过webView展示http://baidu.com网页信息


效果图

    



代码实例:


导入jar包


xUtils  和  gson 的jar包


添加依赖:

compile 'com.android.support:design:26.0.0-alpha1'

compile 'com.android.support:recyclerview-v7:25.3.1'


一, 页面:

main_activity.html

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="bw.com.day18_test.MainActivity">

<android.support.design.widget.TabLayout
    android:layout_width="match_parent"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值