ArrayAdapter简单实现 Listview
来源:互联网 发布:个人信用数据库包含 编辑:程序博客网 时间:2024/06/13 02:29
ArrayAdapter简单实现 Listview
你现在受的苦,未来都会照亮你的路,告诉所有正在路上奋斗的人,即使路途遥远,即使梦想遥遥无期,但只要坚持下去,总会得到最好的结果……
package com.crazyit.ui.adapterview;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.widget.ArrayAdapter;import android.widget.ListView;public class ArrayAdapterActivity extends AppCompatActivity { private ListView lv1,lv2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_array_adapter); //初始化控件 lv1 = (ListView) findViewById(R.id.lv1); lv2 = (ListView) findViewById(R.id.lv2); //定义一个数组 String[] str1 = new String[]{"魏国","蜀国","吴国"}; //将数组包装成ArrayAdapter ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(getApplication(),R.layout.array_item,str1); //为listView设置Adapter lv1.setAdapter(adapter1); //定义一个数组 String[] str2 = new String[]{"JAVA","Android","HTML","PHP"}; ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(this,R.layout.checked_item,str2); //为listView设置Adapter lv2.setAdapter(adapter2); }}
布局文件
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.crazyit.ui.adapterview.ArrayAdapterActivity"> <!--使用红色分割线--> <ListView android:id="@+id/lv1" android:layout_width="match_parent" android:layout_height="wrap_content" android:divider="#f00" //设置分割线 android:dividerHeight="3px" android:headerDividersEnabled="false" /> <!--使用绿色分割线--> <ListView android:id="@+id/lv2" android:layout_width="match_parent" android:layout_height="wrap_content" android:divider="#0f0" android:dividerHeight="3px" android:headerDividersEnabled="false" /></LinearLayout>
下面是Adapter提供的列表项的数据
<?xml version="1.0" encoding="utf-8"?><TextView android:gravity="center_horizontal" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/textview" android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="24sp" android:padding="10dp" android:textColor="#409" android:shadowColor="#f0f" android:shadowDy="3" //设置阴影的颜色和宽度 android:shadowDx="3" android:shadowRadius="3" />
<?xml version="1.0" encoding="utf-8"?><CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/textview2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:checkMark="@drawable/ok" android:shadowColor="#00f" android:shadowDx="3" android:shadowDy="3" //设置阴影的颜色和宽度 android:shadowRadius="3" android:textSize="24sp"></CheckedTextView>
0 0
- ArrayAdapter简单实现 Listview
- LIstview-列表控件的简单实现ArrayAdapter
- ArrayAdapter实现ListView
- Android 基础-最简单的listView实现 ArrayAdapter
- 应用ArrayAdapter和ListView实现简单的上下滚动显示
- Android-LIstview-列表控件的简单实现ArrayAdapter
- ListView使用ArrayAdapter、BaseAdapter实现
- ArrayAdapter、ListActivity、SimpleAdapter实现ListView
- android中ListView+ArrayAdapter简单使用
- ListView与ArrayAdapter的简单用法
- listview简单应用之ArrayAdapter(一)
- Android ListView ArrayAdapter 的简单使用
- android组件ListView之ArrayAdapter简单使用
- ListView组件和ArrayAdapter的实现
- 自定义ArrayAdapter+ListView实现笔记本的App
- ArrayAdapter在ListView的详解实现
- ListView-Arrayadapter
- ListView ArrayAdapter
- RSA 加密及算法实现
- 获取手机系统大小、可用空间大小,设备可用内存及当前应用所占内存等
- 一些数据挖掘比赛经验
- 用StringBuffer与String解决同一个问题
- IOS7 开发注意事项
- ArrayAdapter简单实现 Listview
- [XML]学习笔记(八)XSLT
- IOS 消息机制(NSNotificationCenter)
- bzoj3533【SDOI2014】向量集
- GCDAsyncSocket
- linux下gcc下makefile文件的编写
- 个人iOS 开发使用的Xcode插件
- 中文停用词词表
- C++代码收藏