怎样在Android中ListView与ArrayAdapter配合使用
16lz
2021-12-04
[代码]main.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android" Android:orientation="vertical" android:layout_width="fill_parent" Android:layout_height="fill_parent"> <!-- 注意这里的Android:id是使用内置的--> <ListView Android:id="@android:id/list " Android:layout_width="fill_parent" Android:layout_height="wrap_content"></ListView> </LinearLayout>
[代码][Java]代码
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String[]items ={"aaa","bbbb","cccc"}; ArrayAdapter arrayAdapter = new ArrayAdapter(this,Android.R.layout.simple_list_item_1 ,items); setListAdapter(arrayAdapter); }
原文详细:http://android.662p.com/thread-493-1-1.html
更多相关文章
- 箭头函数的基础使用
- NPM 和webpack 的基础使用
- Python list sort方法的具体使用
- 【阿里云镜像】使用阿里巴巴DNS镜像源——DNS配置教程
- Android(安卓)通知的基本用法示例代码
- Android软键盘使用
- android EditText 去除边框
- Android(安卓)使用com.j256.ormlite
- android webview字体大小的控制