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

深圳做网站公司 南山搜索图片

深圳做网站公司 南山,搜索图片,广州建站网络推广公司,ui设计是什么专业学的前言 前面在适配器章节&#xff0c;已经介绍了ListView的作用(干什么的)&#xff0c;这节将主要介绍如何去设计ListView页面视图。 思考 列表视图需要些什么&#xff1f; 1. 列表项容器&#xff08;装载各列表项的容器&#xff09;&#xff1a;<ListView/> 2. 列表项布局…

前言

前面在适配器章节,已经介绍了ListView的作用(干什么的),这节将主要介绍如何去设计ListView页面视图。

思考

 列表视图需要些什么?

1. 列表项容器(装载各列表项的容器):<ListView/>

2. 列表项布局:my_list_item.xml

3. 列表所需数据:List<Object>、Adapter(桥梁)

 代码示例

下面的代码示例,是从我的项目中copy的是一个很好的例子

 

// 1. 列表项容器:activity_charge_up.xml(仅展示了相关部分)
<ListViewandroid:id="@+id/cuisine_list"android:layout_width="match_parent"android:layout_height="match_parent">
</ListView>// 2. 列表项布局:cuisine_list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="60dp"android:background="#FEFCEB"android:layout_margin="10dp"><TextViewandroid:id="@+id/cuisineName"android:layout_width="75dp"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="20dp"android:text="西红柿炒鸡蛋"android:textColor="@color/black"android:textSize="12sp"></TextView><TextViewandroid:id="@+id/cuisinePrice"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="5dp"android:layout_toRightOf="@+id/cuisineName"android:text="¥99.90"android:textColor="#FF1100"android:textSize="12sp"android:textStyle="bold"></TextView><Buttonandroid:id="@+id/subCuisine"android:layout_width="30dp"android:layout_height="30dp"android:layout_centerVertical="true"android:layout_toLeftOf="@+id/cuisineQuantity"android:textSize="5dp"android:background="@drawable/sub"></Button><TextViewandroid:id="@+id/cuisineQuantity"android:layout_width="20dp"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_toLeftOf="@+id/addCuisine"android:gravity="center"android:text="0"android:textColor="@color/black"android:textSize="10dp"></TextView><Buttonandroid:id="@+id/addCuisine"android:layout_width="30dp"android:layout_height="30dp"android:background="@drawable/add"android:layout_alignParentRight="true"android:layout_centerVertical="true"android:textSize="5sp"></Button></RelativeLayout>
</RelativeLayout>

适配器的使用很简单:

MyAdapter myAdapter = new MyAdapter(参数); 
ListView cuisineList = findById(R.layout.cuisine_list);
cuisineList.setAdapter(myAdapter);

复杂的是适配器的业务逻辑(适配器的实现):

    对于适配器的实现,可以参考前面适配器章节,这里就不再做具体的代码示例。

    在实际需求中,在适配器中你可能需要接受多个参数,你需要处理列表项的交互(譬如点击),你可能也需要即时地去改变列表项所在页面的相关控件内容(因为修改列表项一般也需要修改其他页面元素)。

 导航栏

其实学习ListView后,当想到设计导航栏后,可能会想到它能否胜任导航栏的设计呢?

        并不好去设计。首先,导航栏不仅有竖直的,还有水平的;其二,导航栏不仅仅是导航栏的变化,更涉及到导航内容的变化。

        所以导航栏的设计,一般有以下两种策略:

        (1) 自己设计:导航(LinearLayout)、导航页面内容(removeAllViews+addView+LayoutInflater)

        (2) 可用控件FragmentViewPager(参考链接:Android四种底部导航栏实现)

后言

 下一节,将介绍RecyclerView的相关知识

http://www.15wanjia.com/news/21794.html

相关文章:

  • v2ex 网站建设日本和韩国是亚洲的国家
  • 自己建网站做代理商如何做网页链接
  • 百度推广怎么做的网站百度客服电话号码
  • 广州交易中心360seo关键词优化
  • 大学生做政府网站企业管理培训课程网课
  • 赣州建网站余姚网站seo运营
  • 重庆璧山新闻最新消息百度自然搜索排名优化
  • 高校网站建设资料库软文文案
  • 北京黄村专业网站建设价钱云搜索网页版入口
  • PS做游戏网站需要做几个网页全球搜索引擎排行榜
  • 怎样用css做网站推广平台哪个效果最好
  • 手机怎么做自己的网站网址推荐
  • 阿里去可以做几个网站百度网站关键词优化
  • 那个相亲网站做的比较好搜索引擎的四个组成部分及作用
  • 做网站设计提成赚钱吗上海网络推广服务公司
  • 做网站优化多少钱网络广告营销有哪些
  • wordpress好的插件seo是什么意思
  • 带动画的网站模板天津疫情最新消息
  • 微擎如何做网站网络推广员好做吗
  • 深圳罗湖做网站公司哪家好百度网盘电脑版官网
  • 手机端的网站怎么做的百度服务中心
  • 广州做地铁的公司网站可以免费投放广告的平台
  • 顺德品牌网站建设优惠网站开发公司排名
  • 网站建设 site yudwl.com个人如何建立免费网站
  • 怎么制作官网关键词优化快速
  • 徐州建设网站价格网站推广的公司
  • 网站制作html代码百度一下你就知道了百度
  • 京美建站有代码吗网页设计框架
  • 科技备案企业网站公众号软文素材
  • 建设银行住房公积网站互联网广告价格