Android重要控件———ListView
2016-02-29 21:16
513 查看
<RelativeLayout 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" > <ListView android:id="@+id/list_view" android:layout_width="match_parent" android:layout_height="match_parent"> </ListView> </RelativeLayout>
package com.example.listviewtest; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; public class ListviewtestActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listviewtest); ListView lv =(ListView)findViewById(R.id.list_view); String[] data ={"apple","banana","watermelon","pear","peach","grape","mango","strawberry","tomato","pineapple","cherry","tea","coin","hha"}; ArrayAdapter<String> adapter = new ArrayAdapter<String>(ListviewtestActivity.this,android.R.layout.simple_list_item_1,data); lv.setAdapter(adapter); } }
![](http://images2015.cnblogs.com/blog/899124/201602/899124-20160229211455580-444107998.png)
相关文章推荐
- Android性能分析——Activity启动速度分析工具
- Material Design -- TextInputLayout
- Android控件postDelayed用法,View自带的定时器
- 程序加载中...(ProgressDialog和线程整合应用)
- 关于间接调用对象问题
- android进阶 重写view来实现全新控件
- Android之增量更新
- Android之增量更新
- android 进阶自定义控件1
- 初识-Android之智能短信项目相关技术整理
- Android源码
- android自定义一个带进度条的button
- Android应用的电池使用解析
- android提高进程优先级的若干方法
- Android创建组合控件
- Android环境搭建时的问题
- Adding the Action Bar --1.1
- android studio 关闭鼠标悬停自动显示文档
- Android动画原理总结
- Android MediaCodec学习