(仿头条APP项目)7.首页标签页完善和微头条页面设计实现
生活随笔
收集整理的這篇文章主要介紹了
(仿头条APP项目)7.首页标签页完善和微头条页面设计实现
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
文章目錄
- 一.首頁標(biāo)簽頁完善
- 效果圖
- 具體實(shí)現(xiàn)
- 二.微頭條頁面設(shè)計(jì)實(shí)現(xiàn)
- 效果圖
- 實(shí)現(xiàn)思路
- 具體實(shí)現(xiàn)
- 布局
- 微頭條頁面實(shí)體類
- 業(yè)務(wù)邏輯代碼
一.首頁標(biāo)簽頁完善
- 在之前已經(jīng)把首頁北京標(biāo)簽的新聞列表頁面基本上開發(fā)完成了。完成了一個(gè)頁面的開發(fā)之后,其他頁面只需要改相關(guān)的標(biāo)題,圖片,日期等信息就行了。信息直接從服務(wù)端獲取。
效果圖
具體實(shí)現(xiàn)
將MyApi中的getNewList方法增加一個(gè)變量(具體標(biāo)簽頁信息的地址)和BaseUrl地址拼接。
在NewListFragment 中定義一個(gè)變量存放具體標(biāo)簽頁的地址
添加帶參數(shù)loadFirstUrl的構(gòu)造方法,這樣就可以在創(chuàng)建NewListFragment對象時(shí)將loadFirstUrl傳入。
在HomeFragment中的MyPagerAdapter構(gòu)造方法中將標(biāo)簽頁地址傳入NewListFragment對象中。
二.微頭條頁面設(shè)計(jì)實(shí)現(xiàn)
效果圖
實(shí)現(xiàn)思路
- 在TalkFragment中添加圖片按鈕點(diǎn)擊事件來切換列表視圖和網(wǎng)格視圖
- 獲取服務(wù)端數(shù)據(jù)
- 設(shè)置適配器
具體實(shí)現(xiàn)
布局
主頁面fragment_pic.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:orientation="vertical" 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" ><RelativeLayoutandroid:background="#FF4444"android:layout_width="match_parent"android:layout_height="40dp"><TextViewandroid:text="微頭條"android:layout_centerInParent="true"style="@style/Title" /><ImageViewandroid:id="@+id/switchBtn"android:layout_centerVertical="true"android:layout_alignParentRight="true"style="@style/Switch" /></RelativeLayout><FrameLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:padding="10dp"><ListViewandroid:id="@+id/listview"android:dividerHeight="10dp"android:layout_width="match_parent"android:layout_height="match_parent"></ListView><GridViewandroid:visibility="gone"android:id="@+id/gridview"android:numColumns="2"android:horizontalSpacing="10dp"android:verticalSpacing="10dp"android:layout_width="match_parent"android:layout_height="match_parent"></GridView></FrameLayout></LinearLayout>列表和網(wǎng)格布局item_list_pic
<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:orientation="vertical" 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:padding="10dp" android:background="#FFFFFF" android:layout_height="match_parent"><ImageViewandroid:id="@+id/item_image_pic"android:background="#C80000"android:layout_centerVertical="true"android:layout_alignParentRight="true"android:layout_width="match_parent"android:layout_height="200dp" /><TextViewandroid:id="@+id/item_title_pic"android:layout_width="match_parent"android:lines="1"android:textSize="23sp"android:text="我是標(biāo)題"android:layout_height="wrap_content" /></LinearLayout>微頭條頁面實(shí)體類
GsonFormat插件快捷創(chuàng)建
PicData
業(yè)務(wù)邏輯代碼
- 在TalkFragment中添加圖片按鈕點(diǎn)擊事件來切換列表視圖和網(wǎng)格視圖
- 獲取服務(wù)端數(shù)據(jù)
- 設(shè)置適配器
總結(jié)
以上是生活随笔為你收集整理的(仿头条APP项目)7.首页标签页完善和微头条页面设计实现的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: (Java集合框架)Map集合
- 下一篇: (仿头条APP项目)8.新闻详情页面实现