2019独角兽企业重金招聘Python工程师标准>>>

还在为系统黑色的list而烦恼么,不罗嗦 ,先上图

如果只是功能的问题,那么你就要写自己的listview了,黑色的永远不能拿出去丢人,不过这个也挺丢人的,哈哈,各位,不要嘲笑我这个小菜鸟啊

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical" android:background="#E0E0E0"><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="100dp"android:orientation="vertical"android:background="@drawable/group_bg"     ><ImageView android:id="@+id/UserImage"android:layout_width="80dp"android:layout_height="80dp"/><TextView android:id="@+id/UserName"android:layout_width="fill_parent"android:layout_height="80dp"android:layout_toRightOf="@+id/UserImage"android:gravity="center"/></RelativeLayout><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="30dp"android:orientation="vertical">        </LinearLayout><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="300dp"android:orientation="vertical"android:background="#FCFCFC"android:paddingLeft="20dp"android:paddingRight="20dp"><ListView android:id="@+id/listview"android:layout_width="fill_parent"android:layout_height="fill_parent"  android:listSelector="@drawable/grouplist_item_bg"          android:drawSelectorOnTop="true"android:cacheColorHint="#00000000"android:divider="@drawable/group_divider"android:dividerHeight="2.0px" android:layout_weight="0.0"></ListView></LinearLayout></LinearLayout>

list_item.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="40dp"xmlns:android="http://schemas.android.com/apk/res/android"><TextView android:gravity="center" android:id="@+id/groupItem" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="18.0sp"android:textColor="#9D9D9D"/>
</LinearLayout>
package com.information;import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;public class TestInformationListViewActivity extends Activity {/** Called when the activity is first created. */private TextView userName;private ImageView userImage;private ListView listView;List<HashMap<String,String>> list;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);userName = (TextView)findViewById(R.id.UserName);userImage = (ImageView)findViewById(R.id.UserImage);userName.setText("hello...");//改变用户的头像Drawable drawable = getResources().getDrawable(R.drawable.ic_launcher);userImage.setBackgroundDrawable(drawable);listView = (ListView)findViewById(R.id.listview);list = new ArrayList<HashMap<String,String>>();for(int i=0 ;i<5;i++){if(i==0){HashMap<String,String> map = new HashMap<String,String>();map.put("first", "设置");list.add(map);}else if(i==1){HashMap<String,String> map = new HashMap<String,String>();map.put("first", "账号管理");list.add(map);}else if(i==2){HashMap<String,String> map = new HashMap<String,String>();map.put("first", "意见反馈");list.add(map);}else if(i==3){HashMap<String,String> map = new HashMap<String,String>();map.put("first", "浏览模式");list.add(map);}else {HashMap<String,String> map = new HashMap<String,String>();map.put("first", "关于");list.add(map);}}SimpleAdapter simpleAdapter = new SimpleAdapter(this, list, R.layout.list_item, new String[]{"first"}, new int[]{R.id.groupItem});listView.setAdapter(simpleAdapter);listView.setOnItemClickListener(new ButtonListClickListener());}class ButtonListClickListener implements OnItemClickListener{@Overridepublic void onItemClick(AdapterView<?> parent, View view, int position,long id) {// TODO Auto-generated method stubToast.makeText(TestInformationListViewActivity.this, (CharSequence) list.get(position).get("first"), 0).show();}}
}

转载于:https://my.oschina.net/lhjtianji/blog/54536

自定义listview相关推荐

  1. 自定义listView添加滑动删除功能

    今天研究了一下android里面的手势,结合昨天学习的自定义View,做了一个自定义的listview,继承自listView,添加了条目的滑动手势操作,滑动后出现一个删除按钮,点击删除按钮,触发一个 ...

  2. Android 自定义ListView单击事件失效

    因为自带的listView不能满足项目需求,通过实现自己的Adapter去继承ArrayAdapter 来实现自定义ListView的Item项目. 出现点击ListView的每一项都不会执行setO ...

  3. 自定义ListView【通用】适配器并实现监听控件

    ListView:在Android应用开发过程中属于最常用的系统组件之一,当然可能童鞋们问为什么会突然游戏开发中讲这个,呵呵,其实在游戏开发中,也会常常使用到系统组件,比如游戏排行榜,简单的游戏关卡选 ...

  4. 自定义ListView背景(解决了拖动变黑的效果)

    美化你的android程序:自定义ListView背景 文章分类:移动开发   在Android中,ListView是最常用的一个控件,在做UI设计的时候,很多人希望能够改变一下它的背景,使他能够符合 ...

  5. Android 自定义 ListView 显示网络上 JSON 格式歌曲列表

    本文内容 环境 项目结构 演示自定义 ListView 显示网络上 JSON 歌曲列表 参考资料 本文最开始看的是一个国人翻译的文章,没有源代码可下载,根据文中提供的代码片段,自己新建的项目(比较可恶 ...

  6. 解决listview与scroll冲突,自定义listview高度

    //自定义listview的高度 private void listviewHeight(ListView list){ ListAdapter listadapte = list.getAdapte ...

  7. android中上拉下滑布局,3年以上勿进!最简单的Android自定义ListView下拉刷新与上拉加载,代码直接拿去用~...

    本文主要针对开发新手,手写实现一个最简单Android自定义listview下拉刷新和上拉加载demo. 不喜可喷,欢迎大佬留言指点. 效果图 一:编写需要在ListView中增加头加载的布局文件,与 ...

  8. android 自定义 滑动删除,Android_Android ListView实现仿iPhone实现左滑删除按钮的简单实例,需要自定义ListView。这里就交Fl - phpStudy...

    Android ListView实现仿iPhone实现左滑删除按钮的简单实例 需要自定义ListView.这里就交FloatDelListView吧. 复写onTouchEvent方法.如下: @Ov ...

  9. Android自定义ListView示例,以创建不可滚动的ListView

    In this tutorial we'll override the ListView class to suit it according to our requirements in the a ...

  10. 自定义ListView实现任意View跑马灯效果

    自定义ListView实现任意View跑马灯效果 标签(空格分隔): 开源项目 看图 话不多说,先来看下大图效果吧,这里的GIF录制有点渣,不过真实的跑出来的效果还是挺不错的. 前言 最近项目中会加入 ...

最新文章

  1. travis-ci如何配置android
  2. 你为什么“啃不动”你手中的技术书?
  3. Standalone WSGI Containers
  4. 实验一:SQL server 2005高可用性之----日志传送
  5. python3 gzip 压缩/解压
  6. 计算机专业要学几门课呀,计算机专业学生一定要学好这几门课!
  7. 【转】理解Azure订阅,账户,活动目录AD,租户等概念
  8. Qt DLL总结-创建及调用QT的 DLL
  9. Shell脚本学习-阶段十二-在CentOS 7上给一个网卡分配多个IP地址
  10. Python爬虫实战源码合集(持续更新)
  11. 北京市延庆县门户网站改版及电子政务网站群建设项目落定西部动力
  12. 处理App状态改变的策略
  13. iweboffice之word——常用属性的设置
  14. [RubyOnRails]一些网址
  15. cpp读取分数并进行求和化简
  16. 网易秋招编程题——优雅的点
  17. 线性回归(线性拟合)与非线性回归(非线性拟合)原理、推导与算法实现(一)
  18. Keras中那些学习率衰减策略
  19. Docker架构部署及镜像制作,免费容器云体验
  20. 在这里,你终究会真正地失败

热门文章

  1. python 列表索引第一个字典_python开发(第三篇):python基本数据类型(列表,元组,字典)...
  2. android+4.3+root,安卓4.3要怎么root?安卓4.3 root教程
  3. linux oracle em使用,案例:五步解决linux操作系统Oracle EM乱码的问题
  4. Swift 中枚举、结构体、类(enum、struct、class)
  5. 编译安装_在Centos7下编译安装新版本内核
  6. mysql设置edit_可以使用mysql自己带的config edit
  7. 计算机辅助教育的可行性和存在的问题,论计算机辅助教学存在的问题及解决思路..docx...
  8. Mogees将手势识别技术运用于新产品
  9. 你玩的音游可能真是AI生成的,Love Live!工作室发了篇论文,用AI节省50%作谱时间...
  10. 苹果的新Siri:不男,也不女