当前位置: 首页 > wzjs >正文

青岛网站建设方案公司企业年报信息公示流程

青岛网站建设方案公司,企业年报信息公示流程,全网营销书籍,中山精品网站建设策划书文章目录 1. 功能需求2. 代码实现过程1. 编写布局文件2. 创建商品分类(Adapter)适配器3. 实现商品分类Activity4. 在res/values/ 下新建 array.xml ,用于添加商品分类数据5. 效果演示 6. 关于作者其它项目视频教程介绍 1. 功能需求 显示商品分…

文章目录

    • 1. 功能需求
    • 2. 代码实现过程
        • 1. 编写布局文件
        • 2. 创建商品分类(Adapter)适配器
        • 3. 实现商品分类Activity
        • 4. 在res/values/ 下新建 array.xml ,用于添加商品分类数据
        • 5. 效果演示
    • 6. 关于作者其它项目视频教程介绍

1. 功能需求

在这里插入图片描述

  1. 显示商品分类数据
  2. 当分类数据超过一屏时,可以左右滑动显示
  3. 点击当前商品分类时,需要高亮显示,并且默认第一个商品分类选中

2. 代码实现过程

1. 编写布局文件

创建一个布局文件activity_main.xml,用户显示商品分类页的内容:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"><!-- TODO: Update blank fragment layout --><androidx.appcompat.widget.Toolbarandroid:id="@+id/toolbar"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="@color/purple_200"app:title="商品分类"app:titleTextColor="@color/white" /><androidx.appcompat.widget.LinearLayoutCompatandroid:layout_below="@id/toolbar"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><androidx.appcompat.widget.LinearLayoutCompatandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><androidx.recyclerview.widget.RecyclerViewandroid:id="@+id/topRecyclerView"android:layout_width="match_parent"android:layout_height="wrap_content" /><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"><androidx.recyclerview.widget.RecyclerViewandroid:id="@+id/recyclerView"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#f5f5f5"app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /><androidx.appcompat.widget.LinearLayoutCompatandroid:id="@+id/empty_view"android:layout_width="match_parent"android:layout_height="match_parent"android:gravity="center"android:orientation="vertical"><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="80dp"android:src="@mipmap/img_empty" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="10dp"android:text="暂无数据~" /></androidx.appcompat.widget.LinearLayoutCompat></RelativeLayout></androidx.appcompat.widget.LinearLayoutCompat></androidx.appcompat.widget.LinearLayoutCompat></RelativeLayout>
2. 创建商品分类(Adapter)适配器
public class CategoryListAdapter extends RecyclerView.Adapter<CategoryListAdapter.MyHolder> {private List<String> categoryList = new ArrayList<>();private int currentPosition = 0;public void setCategoryList(List<String> categoryList) {this.categoryList = categoryList;notifyDataSetChanged();}@NonNull@Overridepublic MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {return new MyHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_category_list, parent, false));}@Overridepublic void onBindViewHolder(@NonNull MyHolder holder, int position) {//绑定数据holder.tv_category_name.setText(categoryList.get(position));if (position == currentPosition) {holder.category_bg.setVisibility(View.VISIBLE);holder.tv_category_name.setTextColor(Color.parseColor("#333333"));} else {holder.category_bg.setVisibility(View.GONE);holder.tv_category_name.setTextColor(Color.parseColor("#666666"));}holder.itemView.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {if (onItemClickListener != null) {onItemClickListener.onItemClick(position);}}});}@Overridepublic int getItemCount() {return categoryList.size();}static class MyHolder extends RecyclerView.ViewHolder {TextView tv_category_name;View category_bg;public MyHolder(@NonNull View itemView) {super(itemView);tv_category_name =itemView.findViewById(R.id.tv_category_name);category_bg =itemView.findViewById(R.id.category_bg);}}public void setCurrentPosition(int currentPosition) {this.currentPosition = currentPosition;notifyDataSetChanged();}//设置回调public interface OnItemClickListener {void onItemClick(int position);}private OnItemClickListener onItemClickListener;public void setOnItemClickListener(OnItemClickListener onItemClickListener) {this.onItemClickListener = onItemClickListener;}
}

对应布局文件item_category_list.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="wrap_content"android:layout_height="wrap_content"><RelativeLayoutandroid:layout_width="wrap_content"android:layout_height="40dp"android:layout_marginLeft="16dp"android:layout_marginRight="16dp"><Viewandroid:id="@+id/category_bg"android:layout_width="40dp"android:layout_height="6dp"android:layout_alignParentBottom="true"android:layout_centerInParent="true"android:layout_marginBottom="12dp"android:background="#FF8C00" /><TextViewandroid:id="@+id/tv_category_name"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:gravity="center"android:text="新品推荐"android:textColor="#333333" /></RelativeLayout></LinearLayout>
3. 实现商品分类Activity

MainActivity中,初始化控件,绑定adapter,并实现点击事件

public class MainActivity extends AppCompatActivity {private RecyclerView topRecyclerView;private CategoryListAdapter mCategoryListAdapter;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);//初始化控件topRecyclerView = findViewById(R.id.topRecyclerView);//设置布局管理器  可以横向滑动topRecyclerView.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false));//初始化适配器mCategoryListAdapter = new CategoryListAdapter();//设置适配器topRecyclerView.setAdapter(mCategoryListAdapter);//获取数据String[] stringArray = getResources().getStringArray(R.array.goods_type);mCategoryListAdapter.setCategoryList(Arrays.asList(stringArray));//topRecyclerView点击事件mCategoryListAdapter.setOnItemClickListener(new CategoryListAdapter.OnItemClickListener() {@Overridepublic void onItemClick(int position) {mCategoryListAdapter.setCurrentPosition(position);}});}
}
4. 在res/values/ 下新建 array.xml ,用于添加商品分类数据

新建array.xml 文件

<?xml version="1.0" encoding="utf-8"?>
<resources><!--    商品分类-->
<string-array name="goods_type"><item>食品饮料</item><item>日用百货</item><item>母婴用品</item><item>家居电器</item><item>美妆个护</item><item>服饰鞋帽</item><item>数码产品</item><item>文体用品</item><item>医药保健</item><item>宠物用品</item>
</string-array></resources>
5. 效果演示

在这里插入图片描述

6. 关于作者其它项目视频教程介绍

  1. Android新闻资讯app实战:https://www.bilibili.com/video/BV1CA1vYoEad/?vd_source=984bb03f768809c7d33f20179343d8c8
  2. Androidstudio开发购物商城实战:https://www.bilibili.com/video/BV1PjHfeXE8U/?vd_source=984bb03f768809c7d33f20179343d8c8
  3. Android开发备忘录记事本实战:https://www.bilibili.com/video/BV1FJ4m1u76G?vd_source=984bb03f768809c7d33f20179343d8c8&spm_id_from=333.788.videopod.sections
  4. Androidstudio底部导航栏实现:https://www.bilibili.com/video/BV1XB4y1d7et/?spm_id_from=333.337.search-card.all.click&vd_source=984bb03f768809c7d33f20179343d8c8
  5. Android使用TabLayout+ViewPager2实现左右滑动切换:https://www.bilibili.com/video/BV1Mz4y1c7eX/?spm_id_from=333.337.search-card.all.click&vd_source=984bb03f768809c7d33f20179343d8c8

文章转载自:

http://OcC3yeRU.jbxfm.cn
http://gbOHJiHy.jbxfm.cn
http://LWAqMfHh.jbxfm.cn
http://NrKQRQKq.jbxfm.cn
http://SWOhiBmB.jbxfm.cn
http://gGManqb5.jbxfm.cn
http://2dTLEPLM.jbxfm.cn
http://7c9hnvcl.jbxfm.cn
http://xkLfMEeQ.jbxfm.cn
http://ne9BmVsH.jbxfm.cn
http://lMxu4Lo3.jbxfm.cn
http://sRkLogHb.jbxfm.cn
http://f42iCzJb.jbxfm.cn
http://1LCmXTwF.jbxfm.cn
http://VpHfGRC3.jbxfm.cn
http://WdnmqujM.jbxfm.cn
http://ByiD8L5j.jbxfm.cn
http://nHdNgcil.jbxfm.cn
http://XnfoppxL.jbxfm.cn
http://KlCzzhKi.jbxfm.cn
http://Mr2Ut7M7.jbxfm.cn
http://rgIMTH8z.jbxfm.cn
http://RpVhc3JN.jbxfm.cn
http://kKWRdidE.jbxfm.cn
http://4uLUqyTx.jbxfm.cn
http://YLHhXGbt.jbxfm.cn
http://05lHgOhv.jbxfm.cn
http://FGXWXqNy.jbxfm.cn
http://Q3Wq0zOJ.jbxfm.cn
http://xiT69ShK.jbxfm.cn
http://www.dtcms.com/wzjs/655433.html

相关文章:

  • 网络 网站建设教育直播平台搭建
  • 网站反链如何做如何使用凡科建设网站
  • 广东 网站建设 公司排名wordpress 禁止转载
  • 嘉兴制作网站软件阿里服务器怎么做网站服务器
  • 海外百度云网站建设wordpress主题 推荐
  • 普通网站 用多说济南网络推广公司
  • 汽车4s店网站模板wordpress一键安装空间
  • 网站建设对公司来说重要吗大连企业网站哪一家好
  • 提供免费服务器的网站wordpress怎么上传文件
  • 绍兴网站制作计划免费域名app下载
  • 元气森林网络营销案例网站的优化策略
  • 网站 文章 keywords 和主页keywords黄石网站设计
  • 网站建设需要报告济南seo小黑seo
  • 备案用的网站建设方案书怎么写wordpress数组遍历
  • 中国十大购物网站排行榜网页设计素材和制作教程
  • 开关网站建设一键生成app下载
  • 新县住房和城乡规划建设局网站成都百度网站制作
  • 上海建桥学院门户网站知名网站建设联系电话
  • wordpress 企业站主题长沙网约车驾驶员资格证网上报名
  • 网站制作要求济南网站建设哪里好
  • 嘉兴市做网站优化网络营销成功案例
  • 湛江网站开发公司wordpress做商城好吗
  • 企业网站栏目规划的重要性青岛网站建设情况
  • 临安规划建设局网站有没有便宜的注册代理
  • 国外营销网站建设郑州微信公众号网站建设
  • 公司官网用什么建站程序网站开发小图标怎么设置
  • myeclipse做网站的步骤wordpress插件 速度
  • 连接国外网站的app网站标题在线制作
  • 企业制作网站服务怎样制作网页视频
  • 网站企业近一周的热点新闻