說在前面,由于各種adapter,xml布局,bean物體類,Activity,也為了讓看懂,代碼基本都是“簡單粗暴直接不好看”,沒啥okhttp和util工具類之類的封裝,本篇幅可能有點長吧,大佬請放過,哈~
菜雞一枚,寫得不好,有問題的請指教~~
本篇實作效果:
RecyclerView+json+okhttp+glide實作服務分類和熱門主題推薦,顯示,自定義介面實作RecyclerView 子item的點擊事件,點擊對應的item 進入對應的服務,熱門詳情頁面,直接用簡單的Intent 資料傳遞新聞詳情資訊,也可用WebView 加載新聞詳情,

文章內容
- 本篇實作效果:
- 文章導航
- 功能邏輯實作
- 首頁
- 布局
- fragment_home.xml:
- service.item.xml:
- recommend_item.xml:
- news_item.xml
- 配接器
- NewsAdapter
- NewTabAdapter
- RecommendAdapter
- RecycleServiceAdapter
- 跳轉詳情頁面
- 關于點擊跳轉對應的Activity
- CityStateAcivity:
- 關于布局
- 物體類
- CommentBean:
- RecommentBean:
- ResponseBean:
- ServiceBean:
文章導航
一、【Android專案實戰 | 從零開始寫app(一)】 創建專案
二、【Android專案實戰 | 從零開始寫app(二)】實作閃屏頁,啟動app
三、【Android專案實戰 | 從零開始寫app(三)】實作引導頁,進入登錄or主頁面
四、【Android專案實戰 | 從零開始寫app(四)】Okhttp+Gson實作服務端登錄驗證功能
五、【Android專案實戰 | 從零開始寫app(五)】okhttp+gson實作服務端注冊功能
六、【Android專案實戰 | 從零開始寫app(六)】用TabLayout+ViewPager搭建App 框架主頁面底部導航欄
七、【Android專案實戰 | 從零開始寫app(七)】優化主頁導航欄,禁用主頁頁面滑動切換效果
八、【Android專案實戰 | 從零開始寫app(八)】實作app首頁廣告輪播圖切換和搜索跳轉
九、【Android專案實戰 | 從零開始寫app(九)】實作主頁底部新聞模塊資料的決議
十、【Android專案實戰 | 從零開始寫app(10)】Okhttp+glide+json+ListView實作新聞模塊資料的填充顯示
十一、【Android專案實戰 | 從零開始寫app(11)】實作app首頁九宮格服務分類點擊跳轉
十二、【Android專案實戰 | 從零開始寫app(12)】實作app首頁熱門推薦
十三、【Android專案實戰 | 從零開始寫app(13)】實作服務頁面資料的決議
十四、【Android專案實戰 | 從零開始寫app(14)】實作用戶中心模塊清除token退出登錄&資訊修改等功能
十五、【Android專案實戰 | 從零開始寫app(15)】實作發布模塊…
功能邏輯實作
首頁
在HomeFragment 加入如下代碼:
package com.example.myapp.fragment;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.example.myapp.R;
import com.example.myapp.activity.ApponitmentActivity;
import com.example.myapp.activity.BannerWebView;
import com.example.myapp.activity.BusActivity;
import com.example.myapp.activity.CityStateActivity;
import com.example.myapp.activity.LivingPayActivity;
import com.example.myapp.activity.NewSearchActivity;
import com.example.myapp.activity.NewsWebViewActivity;
import com.example.myapp.activity.ParkActivity;
import com.example.myapp.activity.RecommendWebView;
import com.example.myapp.activity.WeiZhangActivity;
import com.example.myapp.adapter.NewTabAdapter;
import com.example.myapp.adapter.RecommendAdapter;
import com.example.myapp.adapter.RecycleServiceAdapter;
import com.example.myapp.bean.BannerBean;
import com.example.myapp.bean.NewsBean;
import com.example.myapp.bean.RecommendBean;
import com.example.myapp.bean.ServiceBean;
import com.example.myapp.utils.APIConfig;
import com.google.android.material.tabs.TabLayout;
import com.google.gson.Gson;
import com.youth.banner.Banner;
import com.youth.banner.adapter.BannerImageAdapter;
import com.youth.banner.holder.BannerImageHolder;
import com.youth.banner.indicator.CircleIndicator;
import com.youth.banner.listener.OnBannerListener;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
/**
* @ProjectName: MyApp
* @Package: com.example.myapp.fragment
* @ClassName: HomeFragment
* @Description:
* @Author: liyingxia
* @CreateDate: 2021/4/13 21:34
*/
public class HomeFragment extends BaseFragment {
private static final String TAG = HomeFragment.class.getSimpleName();
private TextView tv_more,tv_theme,tv_theme_title;
private EditText ed_search;
private Banner banner;
private RecyclerView home_recyclerview,home_recyclerview1;
private RecycleServiceAdapter recycleServiceAdapter;
private List<ServiceBean.RowsBean> rowsBeanList;
private List<RecommendBean.RowsDTO> recommendList;
private RecommendAdapter recommendAdapter;
private NewsBean newsBean;
private NewsAdapter newsAdapter;
private NewTabAdapter newTabAdapter;
private TabLayout tab_layout;
private ListView home_listview;
private ViewPager view_pager;
private OkHttpClient client = new OkHttpClient();
@SuppressLint("HandlerLeak")
private Handler handler = new Handler() {
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
if (msg.what==0) {
ServiceBean serviceBean = (ServiceBean) msg.obj;
rowsBeanList = serviceBean.getRows();
recycleServiceAdapter= new RecycleServiceAdapter(getActivity(),rowsBeanList);
home_recyclerview.setLayoutManager(new GridLayoutManager(getActivity(),5));
home_recyclerview.setAdapter(recycleServiceAdapter);
recycleServiceAdapter.setItemClickListener(new RecycleServiceAdapter.MyItemClickListener() {
@Override
public void onItemClick(View view, int position) {
String url = APIConfig.BASE_URL+"/"+rowsBeanList.get(position).getLink();
Intent intent = null;
if (position==0){
intent = new Intent(getActivity(), CityStateActivity.class);
} else if (position==1) {
intent = new Intent(getActivity(), BusActivity.class);
} else if (position==2) {
intent = new Intent(getActivity(), ApponitmentActivity.class);
} else if (position==3) {
intent = new Intent(getActivity(), LivingPayActivity.class);
} else if (position==4) {
intent = new Intent(getActivity(), WeiZhangActivity.class);
} else if (position==5) {
intent = new Intent(getActivity(), ParkActivity.class);
}
Bundle bundle = new Bundle();
bundle.putString("title",rowsBeanList.get(position).getServiceName());
bundle.putString("url",url);
intent.putExtras(bundle);
getActivity().startActivity(intent);
}
});
}
if (msg.what==1) {
RecommendBean recommendBean = (RecommendBean) msg.obj;
recommendList = recommendBean.getRows();
recommendAdapter = new RecommendAdapter(getActivity(),recommendList);
home_recyclerview1.setLayoutManager(new GridLayoutManager(getActivity(),2));
home_recyclerview1.setAdapter(recommendAdapter);
recommendAdapter.setOnItemClickListener(new RecommendAdapter.OnItemClickListener() {
@Override
public void onItemClick(int position, List<RecommendBean.RowsDTO> list) {
String url = APIConfig.BASE_URL+"/"+list.get(position).getLink();
Toast.makeText(getContext(),"url詳情:"+url,Toast.LENGTH_LONG).show();
Intent intent = new Intent(getActivity(), RecommendWebView.class);
Bundle bundle = new Bundle();
bundle.putString("title",list.get(position).getServiceName());
bundle.putString("url",url);
intent.putExtras(bundle);
getActivity().startActivity(intent);
}
});
}
}
};
@Override
public View initView() {
Log.i(TAG, "首頁的視圖被初始化了");
View view = View.inflate(getContext(), R.layout.fragment_home, null);
ed_search = view.findViewById(R.id.ed_search);
banner = view.findViewById(R.id.banner);
home_recyclerview = view.findViewById(R.id.home_recyclerview);
home_recyclerview1 = view.findViewById(R.id.home_recyclerview1);
home_listview = view.findViewById(R.id.home_listview);
tab_layout = view.findViewById(R.id.tab_layout);
view_pager = view.findViewById(R.id.view_pager);
tv_more = view.findViewById(R.id.tv_more);
tv_theme = view.findViewById(R.id.tv_theme);
tv_theme_title = view.findViewById(R.id.tv_theme_title);
return view;
}
/**
* 解決ScrollView 導致ListView 只顯示一項問題
* @param listView
*/
public static void setListViewHeightBasedOnChildren(ListView listView){
NewsAdapter newsAdapter = (NewsAdapter) listView.getAdapter();
if (newsAdapter==null){
return;
}
int totalHeight=0;
// newsAdapter.getCount() 獲取回傳資料項的數目
for (int i=0;newsAdapter.getCount()>i;i++){
View listItem = newsAdapter.getView(i,null,listView);
// 計算子項View的寬高
listItem.measure(0,0);
// 統計所有子項的總高度
totalHeight+=listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight+(listView.getDividerHeight()*(newsAdapter.getCount()-1));
//getDividerHeight():獲取子項間分隔符占用的高度, params.height 得到整個ListView 完整顯示需要的高度
listView.setLayoutParams(params);
}
@Override
public void initData() {
super.initData();
initSearch();
initBanner();
getServiceData();
getRecommendData();
initNews();
}
// 頂部搜索框
public void initSearch(){
ed_search.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
if (i== EditorInfo.IME_ACTION_SEARCH){
String search = ed_search.getText().toString();
Intent intent = new Intent(getActivity(), NewSearchActivity.class);
intent.putExtra("search",search);
startActivity(intent);
/*HomeFragment fragment = new HomeFragment();
Bundle bundle = new Bundle();
bundle.putString("search",search);
fragment.setArguments(bundle);
return fragment;*/
}
return false;
}
});
tv_more.setOnClickListener(new View.OnClickListener() {
@SuppressLint("ResourceType")
@Override
public void onClick(View view) {
Toast.makeText(getActivity(),"查看更多點擊底部進入",Toast.LENGTH_LONG).show();
}
});
tv_theme.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
/*Intent intent = new Intent(getActivity(), ServiceActivity.class);
startActivity(intent);*/
Toast.makeText(getActivity(),"更多主題點擊全部服務進入",Toast.LENGTH_LONG).show();
}
});
}
// Banner輪播圖
public void initBanner(){
//網路加載圖片
List<BannerBean.RowsDTO> list = new ArrayList<>();
list.add(new BannerBean.RowsDTO("http://124.93.196.45:10002/profile/home1.png", null));
list.add(new BannerBean.RowsDTO("http://124.93.196.45:10002/profile/home2.png", null));
list.add(new BannerBean.RowsDTO("http://124.93.196.45:10002/profile/home3.png", null));
list.add(new BannerBean.RowsDTO("http://124.93.196.45:10002/profile/home4.png", null));
banner.setAdapter(new BannerImageAdapter<BannerBean.RowsDTO>(list) {
@Override
public void onBindView(BannerImageHolder holder, BannerBean.RowsDTO data, int position, int size) {
//BannerImageHolder 圖片加載自己實作
Glide.with(getActivity())
.load(data.getImgUrl())
.apply(RequestOptions.bitmapTransform(new RoundedCorners(30)))
.into(holder.imageView);
}
}).addBannerLifecycleObserver(this)//添加生命周期觀察者
.setIndicator(new CircleIndicator(getActivity()))
.setOnBannerListener(new OnBannerListener() {
@Override
public void OnBannerClick(Object o, int position) {
// getIntent(position);
Intent intent = new Intent(getActivity(), BannerWebView.class);
Bundle bundle = new Bundle();
bundle.putString("url",list.get(position).getImgUrl());
intent.putExtras(bundle);
getActivity().startActivity(intent);
}
});
}
// 請求全部服務
private void getServiceData() {
Request request = new Request.Builder()
.url(APIConfig.BASE_URL+"/service/service/list")
.build();
try {
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.i("onFailure",e.getMessage());
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()) {
final String result = response.body().string();
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Gson gson = new Gson();
ServiceBean serviceBean = gson.fromJson(result, ServiceBean.class);
Message msg = new Message();
msg.what=0;
msg.obj=serviceBean;
handler.sendMessage(msg);
}
});
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
// 主題推薦
public void getRecommendData(){
Request request = new Request.Builder()
.url(APIConfig.BASE_URL+"/service/service/list?pageNum=1&pageSize=10")
.build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.i("onFailure",e.getMessage());
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()) {
final String recommend = response.body().string();
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Gson gson = new Gson();
RecommendBean recommendBean = gson.fromJson(recommend,RecommendBean.class);
Message msg = new Message();
msg.what=1;
msg.obj=recommendBean;
handler.sendMessage(msg);
}
});
}
}
});
}
// 新聞資料
public void initNews(){
String[] title = {"時政","電視","旅游","視頻","廣播","基層"};
List<Fragment> fragmentlist;
fragmentlist = new ArrayList<>();
fragmentlist.add(new NShizhengFragment());
fragmentlist.add(new NTVFragment());
fragmentlist.add(new NTravelFragment());
fragmentlist.add(new NvideoFragment());
fragmentlist.add(new NbrodcastFragment());
fragmentlist.add(new NJicengFragment());
getNewsData();
newTabAdapter = new NewTabAdapter(getChildFragmentManager(),fragmentlist,title);
newsAdapter = new NewsAdapter();
view_pager.setAdapter(newTabAdapter);
tab_layout.setupWithViewPager(view_pager);
}
// 新聞請求
public void getNewsData(){
Request request = new Request.Builder()
.url(APIConfig.BASE_URL+"/press/press/list")
.build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.i("onFailure",e.getMessage());
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()) {
String result = response.body().string();
Log.i("請求成功",result);
Gson gson = new Gson();
newsBean = gson.fromJson(result, NewsBean.class);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
home_listview.setAdapter(newsAdapter);
setListViewHeightBasedOnChildren(home_listview);
home_listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Intent intent = new Intent(getActivity(), NewsWebViewActivity.class);
ImageView new_img = view.findViewById(R.id.new_img);
new_img.setDrawingCacheEnabled(Boolean.TRUE);
intent.putExtra("bitmap",new_img.getDrawingCache());
intent.putExtra("title",newsBean.getRows().get(i).getTitle());
intent.putExtra("time",newsBean.getRows().get(i).getCreateTime());
intent.putExtra("content",newsBean.getRows().get(i).getContent());
/* Bundle bundle = new Bundle();
bundle.putString("img",newsBean.getRows().get(i).getImgUrl());
bundle.putString("title",newsBean.getRows().get(i).getTitle());
bundle.putString("content",newsBean.getRows().get(i).getContent());
bundle.putString("time",newsBean.getRows().get(i).getContent());
intent.putExtras(bundle);*/
getActivity().startActivity(intent);
}
});
}
});
}
}
});
}
// 新聞配接器
public class NewsAdapter extends BaseAdapter {
@Override
public int getCount() {
return newsBean!=null ? newsBean.getRows().size() : 0;
}
@Override
public Object getItem(int i) {
return newsBean.getRows().get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
ViewHolder holder;
if (view==null) {
view = View.inflate(getContext(), R.layout.news_item,null);
holder = new ViewHolder();
holder.new_title = view.findViewById(R.id.new_title);
holder.new_context = view.findViewById(R.id.new_context);
holder.new_create = view.findViewById(R.id.new_date);
holder.likeNumber = view.findViewById(R.id.likeNumber);
holder.viewsNumber = view.findViewById(R.id.viewsNumber);
holder.new_img = view.findViewById(R.id.new_img);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
holder.likeNumber.setText(newsBean.getRows().get(i).getLikeNumber()+"");
holder.viewsNumber.setText(newsBean.getRows().get(i).getViewsNumber()+"");
holder.new_create.setText(newsBean.getRows().get(i).getCreateTime());
holder.new_context.setText(newsBean.getRows().get(i).getContent());
holder.new_title.setText(newsBean.getRows().get(i).getTitle());
String url = APIConfig.BASE_URL+newsBean.getRows().get(i).getImgUrl();
Glide.with(getActivity()).load(url).into(holder.new_img);
return view;
}
class ViewHolder{
TextView new_title;
TextView new_context;
TextView new_create;
ImageView new_img;
TextView viewsNumber;
TextView likeNumber;
}
}
}
布局
在layout 目錄新建下面對應的xml檔案
fragment_home.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#DFDFDF"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!--頂部搜索框-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="vertical"
android:background="#1A5BDD">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="36dp"
android:layout_marginLeft="24dp"
android:layout_marginTop="11dp"
android:layout_marginRight="24dp"
android:background="@drawable/shape_search_box"
android:gravity="center_horizontal"
android:orientation="horizontal">
<ImageView
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_marginLeft="13dp"
android:layout_gravity="center_vertical"
android:src="@drawable/home_search_icon"/>
<EditText
android:layout_marginLeft="4dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ed_search"
android:singleLine="true"
android:imeOptions="actionSearch"
android:background="@null"
android:hint="搜索你想看的新聞"
android:textColor="#000"
android:textColorHint="#737373"/>
</LinearLayout>
</LinearLayout>
<com.youth.banner.Banner
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#BBD9F3"
android:id="@+id/banner"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--服務-->
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#B5D6F1"
android:layout_margin="10dp"
android:padding="10dp"
android:id="@+id/home_recyclerview"/>
<!--主題推薦-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
android:background="@drawable/shape_login_form"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="主題推薦"
android:gravity="left"
android:id="@+id/tv_theme_title"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="熱門主題 >"
android:gravity="right"
android:id="@+id/tv_theme"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:id="@+id/home_recyclerview1"/>
</LinearLayout>
<!--新聞-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
android:background="@drawable/shape_login_form"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:id="@+id/tv_more"
android:layout_height="wrap_content"
android:gravity="right"
android:text="查看更多 >"/>
<com.google.android.material.tabs.TabLayout
android:layout_width="match_parent"
android:background="@drawable/shape_login_form"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabTextColor="#121212"
app:tabIndicatorColor="#F8C221"
app:tabSelectedTextColor="#FFC107"
android:layout_height="wrap_content"
android:id="@+id/tab_layout"/>
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/shape_login_form"
android:layout_weight="1">
</androidx.viewpager.widget.ViewPager>
<ListView
android:layout_width="match_parent"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:id="@+id/home_listview"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
service.item.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:layout_height="wrap_content">
<ImageView
android:background="@drawable/category_shape"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:id="@+id/service_img"
android:src="@mipmap/ic_launcher"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/service_name"
android:textSize="20sp"
android:textColor="#131313"
android:layout_gravity="center"
android:text="1111"
/>
</LinearLayout>
recommend_item.xml:

news_item.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="wrap_content"
android:layout_marginTop="15dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="@drawable/item_shape"
android:orientation="horizontal">
<ImageView
android:id="@+id/new_img"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginRight="4dp"
android:src="@mipmap/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="8dp"
android:layout_weight="0.6"
android:weightSum="1"
android:orientation="horizontal">
<TextView
android:id="@+id/new_title"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="20dp"
android:textColor="#5B4CB1"
android:text="我是titl"
android:gravity="center_vertical"
android:singleLine="true"/>
<TextView
android:id="@+id/new_date"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="14dp"
android:layout_gravity="right"
android:text="2020-01-01"
android:layout_marginRight="0dp"
android:gravity="center_vertical"
android:singleLine="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="8dp"
android:layout_weight="0.4"
android:weightSum="1"
android:orientation="horizontal">
<TextView
android:id="@+id/new_context"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="14dp"
android:text="我是新聞內容,,,,,"
android:textColor="#5B4CB1"
android:gravity="center_vertical"
android:singleLine="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="22"
android:drawableLeft="@mipmap/like"
android:id="@+id/likeNumber"
android:layout_marginRight="6dp" />
<TextView
android:text="333"
android:drawableLeft="@mipmap/browse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/viewsNumber"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:padding="10dp"
android:background="#0B7CF4"
android:gravity="center"
android:layout_height="wrap_content">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@mipmap/ic_launcher"
android:layout_gravity="center"
android:id="@+id/theme_img"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="智慧醫療"
android:gravity="center"
android:textSize="20sp"
android:textColor="#FFFFFF"
android:id="@+id/theme_name"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="智慧巴士智慧巴士智慧巴士"
android:gravity="center"
android:textSize="16sp"
android:textColor="#fff"
android:id="@+id/theme_desc"/>
</LinearLayout>
配接器
在adapter目錄下新建下面對應adapter類:

NewsAdapter
在adapter中新建NewsAdapter類,繼承baseAdapter,并重寫幾個方法:
package com.example.myapp.adapter;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import com.bumptech.glide.Glide;
import com.example.myapp.bean.NewsBean;
import com.example.myapp.R;
import com.example.myapp.utils.APIConfig;
import java.util.List;
/**
* @ProjectName: MyApp4
* @Package: com.example.myapp4.adapter
* @ClassName: NewsAdapter
* @Description:,
* @Author: liyingxia
* @CreateDate: 2021/3/31 9:20
*/
public class NewsAdapter extends BaseAdapter {
private List<NewsBean.RowsBean> newsBean;
private Context context;
private List<Fragment> fragmentList;
public NewsAdapter(List<NewsBean.RowsBean> newsBean,List<Fragment> fragmentList) {
this.newsBean = newsBean;
this.fragmentList = fragmentList;
}
@Override
public int getCount() {
// return newsBean!=null ? newsBean.getRows().size() : 0;
return newsBean.size();
}
@Override
public Object getItem(int i) {
return newsBean.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
ViewHolder holder;
if (view==null) {
view = View.inflate(context, R.layout.news_item,null);
holder = new ViewHolder();
holder.new_title = view.findViewById(R.id.new_title);
holder.new_context = view.findViewById(R.id.new_context);
holder.new_create = view.findViewById(R.id.new_date);
holder.likeNumber = view.findViewById(R.id.likeNumber);
holder.viewsNumber = view.findViewById(R.id.viewsNumber);
holder.new_img = view.findViewById(R.id.new_img);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
holder.likeNumber.setText(newsBean.get(i).getLikeNumber());
holder.viewsNumber.setText(newsBean.get(i).getViewsNumber());
holder.new_create.setText(newsBean.get(i).getCreateTime());
holder.new_context.setText(newsBean.get(i).getContent());
holder.new_title.setText(newsBean.get(i).getTitle());
String url = APIConfig.BASE_URL+newsBean.get(i).getImgUrl();
Glide.with(context).load(url).into(holder.new_img);
return view;
}
class ViewHolder{
TextView new_title;
TextView new_context;
TextView new_create;
ImageView new_img;
TextView viewsNumber;
TextView likeNumber;
}
}
NewTabAdapter
這個是新聞分類標題配接器:
package com.example.myapp.adapter;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import java.util.List;
/**
* @ProjectName: MyApp4
* @Package: com.example.myapp4.adapter
* @ClassName: NewTabAdapter
* @Description:
* @Author: liyingxia
* @CreateDate: 2021/3/30 18:11
*/
public class NewTabAdapter extends FragmentPagerAdapter {
private List<Fragment> fragmentList;
private String[] titles;
public NewTabAdapter(@NonNull FragmentManager fm, List<Fragment> fragmentList, String[] titles) {
super(fm);
this.fragmentList = fragmentList;
this.titles = titles;
}
/**
* 回傳當前的fragment
* @param position: 當前頁面的位置
* @return
*/
@NonNull
@Override
public Fragment getItem(int position) {
return fragmentList.get(position);
}
/**
* fragment中的個數
*/
@Override
public int getCount() {
return fragmentList.size();
}
/**
* 回傳當前的標題
*/
@Nullable
@Override
public CharSequence getPageTitle(int position) {
return titles[position];
}
}
RecommendAdapter
展示評論資料的配接器:
package com.example.myapp.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.example.myapp.R;
import com.example.myapp.bean.RecommendBean;
import com.example.myapp.utils.APIConfig;
import java.util.List;
/**
* @ProjectName: MyApp4
* @Package: com.example.myapp4.adapter
* @ClassName: RecommendAdapter
* @Description:
* @Author: liyingxia
* @CreateDate: 2021/4/5 15:58
*/
public class RecommendAdapter extends RecyclerView.Adapter<RecommendAdapter.MyViewHolder> {
private List<RecommendBean.RowsDTO> list;
private LayoutInflater layoutInflater;
private Context context;
// 3. 宣告介面
private OnItemClickListener mOnItemClickListener;
// 1. 定義介面
public interface OnItemClickListener{
void onItemClick(int position, List<RecommendBean.RowsDTO> list);
}
// 2. 提供set方法給Activity/fragment呼叫
public void setOnItemClickListener(OnItemClickListener listener){
mOnItemClickListener = listener;
}
public RecommendAdapter(Context context,List<RecommendBean.RowsDTO> list) {
this.list=list;
this.context = context;
this.layoutInflater = LayoutInflater.from(context);
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = layoutInflater.inflate(R.layout.recommend_item,parent,false);
MyViewHolder myViewHolder = new MyViewHolder(view);
return myViewHolder;
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
holder.theme_name.setText(list.get(position).getServiceName());
holder.theme_desc.setText(list.get(position).getServiceDesc());
Glide.with(context).load(APIConfig.BASE_URL+list.get(position).getImgUrl()).into(holder.theme_img);
}
@Override
public int getItemCount() {
return list.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder{
private TextView theme_name;
private TextView theme_desc;
private ImageView theme_img;
public MyViewHolder(@NonNull View view) {
super(view);
this.theme_desc = view.findViewById(R.id.theme_desc);
this.theme_name = view.findViewById(R.id.theme_name);
this.theme_img = view.findViewById(R.id.theme_img);
// 4. 將監聽傳遞給自定義介面
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mOnItemClickListener!=null) {
mOnItemClickListener.onItemClick(getAdapterPosition(),list);
}
}
});
}
}
}
RecycleServiceAdapter
顯示服務資料的配接器:
package com.example.myapp.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.example.myapp.R;
import com.example.myapp.bean.ServiceBean;
import com.example.myapp.utils.APIConfig;
import java.util.List;
/**
* @ProjectName: MyApp
* @Package: com.example.myapp.adapter
* @ClassName: RecycleServiceAdapter
* @Description:
* @Author: liyingxia
* @CreateDate: 2021/4/23 10:05
*/
public class RecycleServiceAdapter extends RecyclerView.Adapter<RecycleServiceAdapter.MyViewHolder> {
private LayoutInflater layoutInflater;
private List<ServiceBean.RowsBean> rowsBeans;
private Context context;
private MyItemClickListener mItemClickListener;
/**
* 構造方法 傳入引數
* @param context
* @param rowsBeans
*/
public RecycleServiceAdapter(Context context,List<ServiceBean.RowsBean> rowsBeans) {
this.rowsBeans = rowsBeans;
this.context = context;
layoutInflater = LayoutInflater.from(context);
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
// 創建ViewHolder, 回傳每一項的布局
View view = layoutInflater.inflate(R.layout.service_item,parent,false);
MyViewHolder myViewHolder = new MyViewHolder(view,mItemClickListener);
return myViewHolder;
}
// 將資料與控制元件系結
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
holder.service_name.setText(rowsBeans.get(position).getServiceName());
String url = APIConfig.BASE_URL + rowsBeans.get(position).getImgUrl();
Glide.with(context).load(url).into(holder.service_img);
}
// 回傳Item總條數
@Override
public int getItemCount() {
// return 10;
return rowsBeans.size();
}
// 內部類,系結控制元件
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private TextView service_name;
private ImageView service_img;
private MyItemClickListener myListener;
public MyViewHolder(@NonNull View view,MyItemClickListener myItemClickListener) {
super(view);
this.myListener = myItemClickListener;
itemView.setOnClickListener(this);
service_img = view.findViewById(R.id.service_img);
service_name = view.findViewById(R.id.service_name);
}
@Override
public void onClick(View view) {
if (myListener!=null) {
myListener.onItemClick(view,getPosition());
}
}
}
//創建一個回呼介面
public interface MyItemClickListener {
void onItemClick(View view,int position);
}
//在activity中adapter中呼叫此方法,將點擊事件監聽傳遞過去,并賦值給全域監聽
public void setItemClickListener(MyItemClickListener myItemClickListener){
this.mItemClickListener = myItemClickListener;
}
}
跳轉詳情頁面
關于點擊跳轉對應的Activity

ApponitmentActivity,BusActivity,CityStateActivity,LivingPayActivity,ParkActivity,WeiZhangActivity等基本一致,后面需要填充什么內容自己實作,好吧~
這里只放一個:
CityStateAcivity:
package com.example.myapp.activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import com.example.myapp.R;
public class CityStateActivity extends AppCompatActivity {
private Toolbar toolbar;
private WebView webView;
private String title;
private TextView service_name;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_city_state);
toolbar = (Toolbar) findViewById(R.id.toolbar);
webView = (WebView) findViewById(R.id.webView);
service_name = findViewById(R.id.service_name);
initData();
}
private void initData() {
toolbar.setNavigationIcon(R.mipmap.top_bar_left_back);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
Bundle bundle = new Bundle();
bundle = getIntent().getExtras();
String url = bundle.getString("url");
title = bundle.getString("title");
service_name.setText(title);
webView.loadUrl("/"+url);
webView.requestFocusFromTouch();
webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setJavaScriptEnabled(true);
}
}
關于布局

activity_apponitment,activity_bus,activity_weizhang,activity_city_state,activity_liviing_pay,activity_park等xml 檔案布局,這里也是基本都一樣

這里只放其中一個:
<?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=".activity.BusActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar"
android:background="#0B84E4"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="違章查詢"
android:textColor="#fff"
android:id="@+id/service_name"
android:textStyle="bold"
android:textSize="20sp"
android:gravity="center"
android:layout_centerVertical="true"/>
</RelativeLayout>
<WebView
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/webView"/>
</LinearLayout>
物體類
在bean目錄下新建如下:

CommentBean:
package com.example.myapp.bean;
import java.util.List;
/**
* @ProjectName: MyApp4
* @Package: com.example.myapp4.bean
* @ClassName: CommentBean
* @Description:
* @Author: liyingxia
* @CreateDate: 2021/4/3 23:57
*/
public class CommentBean {
private int total;
private int code;
private String msg;
private List<RowsDTO> rows;
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public List<RowsDTO> getRows() {
return rows;
}
public void setRows(List<RowsDTO> rows) {
this.rows = rows;
}
public static class RowsDTO {
private String createTime;
private Object updateBy;
private ParamsDTO params;
private String content;
private String nickName;
private String userName;
private String avatar;
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public Object getUpdateBy() {
return updateBy;
}
public void setUpdateBy(Object updateBy) {
this.updateBy = updateBy;
}
public ParamsDTO getParams() {
return params;
}
public void setParams(ParamsDTO params) {
this.params = params;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public static class ParamsDTO {
}
@Override
public String toString() {
return "RowsDTO{" +
"createTime='" + createTime + '\'' +
", content='" + content + '\'' +
", nickName='" + nickName + '\'' +
", userName='" + userName + '\'' +
", avatar='" + avatar + '\'' +
'}';
}
public RowsDTO(String createTime, String content, String nickName, String userName, String avatar) {
this.createTime = createTime;
this.content = content;
this.nickName = nickName;
this.userName = userName;
this.avatar = avatar;
}
}
}
RecommentBean:
package com.example.myapp.bean;
import java.util.List;
/**
* @ProjectName: MyApp
* @Package: com.example.myapp.bean
* @ClassName: RecommendBean
* @Description:
* @Author: liyingxia
* @CreateDate: 2021/4/5 9:18
*/
public class RecommendBean {
private int total;
private int code;
private String msg;
private List<RowsDTO> rows;
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public List<RowsDTO> getRows() {
return rows;
}
public void setRows(List<RowsDTO> rows) {
this.rows = rows;
}
public static class RowsDTO {
/**
* searchValue : null
* createBy : null
* createTime : 2020-10-12 18:17:23
* updateBy : null
* updateTime : 2020-10-19 16:56:47
* remark : null
* params : {}
* id : 2
* serviceName : 城市地鐵
* serviceDesc : 城市地鐵路線
* serviceType : 1
* imgUrl : /profile/ditie.png
* pid : 1
* isRecommend : 1
* link : metro_query/index
*/
private String createTime;
private String updateTime;
private ParamsDTO params;
private int id;
private String serviceName;
private String serviceDesc;
private String serviceType;
private String imgUrl;
private int pid;
private int isRecommend;
private String link;
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getUpdateTime() {
return updateTime;
}
public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}
public ParamsDTO getParams() {
return params;
}
public void setParams(ParamsDTO params) {
this.params = params;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public String getServiceDesc() {
return serviceDesc;
}
public void setServiceDesc(String serviceDesc) {
this.serviceDesc = serviceDesc;
}
public String getServiceType() {
return serviceType;
}
public void setServiceType(String serviceType) {
this.serviceType = serviceType;
}
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public int getIsRecommend() {
return isRecommend;
}
public void setIsRecommend(int isRecommend) {
this.isRecommend = isRecommend;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public static class ParamsDTO {
}
}
}
ResponseBean:
package com.example.myapp.bean;
/**
* @ProjectName: MyApp4
* @Package: com.example.myapp4.bean
* @ClassName: ResponseBean
* @Description: 請求回應結果
* @Author: liyingxia
* @CreateDate: 2021/4/3 19:31
*/
public class ResponseBean {
/**
* msg : 操作成功
* code : 200
*/
private String msg;
private String code;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@Override
public String toString() {
return "ResponseBean{" +
"msg='" + msg + '\'' +
", code=" + code +
'}';
}
}
ServiceBean:
package com.example.myapp.bean;
import java.util.List;
/**
* @ProjectName: MyApp
* @Package: com.example.myapp.bean
* @ClassName: ServiceBean
* @Description:
* @Author: liyingxia
* @CreateDate: 2021/4/23 10:03
*/
public class ServiceBean {
private int total;
private int code;
private String msg;
private List<RowsBean> rows;
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public List<RowsBean> getRows() {
return rows;
}
public void setRows(List<RowsBean> rows) {
this.rows = rows;
}
public static class RowsBean {
/**
* searchValue : null
* createBy : null
* createTime : 2020-10-12 18:17:23
* updateBy : null
* updateTime : 2020-10-19 16:56:47
* remark : null
* params : {}
* id : 2
* serviceName : 城市地鐵
* serviceDesc : 城市地鐵路線
* serviceType : 1
* imgUrl : /profile/ditie.png
* pid : 1
* isRecommend : 1
* link : metro_query/index
*/
private Object searchValue;
private Object createBy;
private String createTime;
private Object updateBy;
private String updateTime;
private Object remark;
private ParamsBean params;
private int id;
private String serviceName;
private String serviceDesc;
private String serviceType;
private String imgUrl;
private int pid;
private int isRecommend;
private String link;
public Object getSearchValue() {
return searchValue;
}
public void setSearchValue(Object searchValue) {
this.searchValue = searchValue;
}
public Object getCreateBy() {
return createBy;
}
public void setCreateBy(Object createBy) {
this.createBy = createBy;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public Object getUpdateBy() {
return updateBy;
}
public void setUpdateBy(Object updateBy) {
this.updateBy = updateBy;
}
public String getUpdateTime() {
return updateTime;
}
public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}
public Object getRemark() {
return remark;
}
public void setRemark(Object remark) {
this.remark = remark;
}
public ParamsBean getParams() {
return params;
}
public void setParams(ParamsBean params) {
this.params = params;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public String getServiceDesc() {
return serviceDesc;
}
public void setServiceDesc(String serviceDesc) {
this.serviceDesc = serviceDesc;
}
public String getServiceType() {
return serviceType;
}
public void setServiceType(String serviceType) {
this.serviceType = serviceType;
}
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public int getIsRecommend() {
return isRecommend;
}
public void setIsRecommend(int isRecommend) {
this.isRecommend = isRecommend;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public static class ParamsBean {
}
public RowsBean(String serviceName, String serviceDesc, String imgUrl, String link) {
this.serviceName = serviceName;
this.serviceDesc = serviceDesc;
this.imgUrl = imgUrl;
this.link = link;
}
@Override
public String toString() {
return "RowsBean{" +
"serviceName='" + serviceName + '\'' +
", serviceDesc='" + serviceDesc + '\'' +
", imgUrl='" + imgUrl + '\'' +
", link='" + link + '\'' +
'}';
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/280723.html
標籤:其他
