ArrayAdapter
2014-02-25 18:19
190 查看
activity_main.xml
list_view.xml
MainActivity.java
该ArrayAdapter局限在于,只能更改文本内容,无法更改图片
效果图:
<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=".MainActivity" > <ListView android:id="@+id/myListView" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout>
list_view.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/btn_keyboard_key_trans_pressed" /> <TextView android:id="@+id/tv_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="我是文本" android:textSize="24sp" /> </LinearLayout>
MainActivity.java
package com.demo.arrayadapter; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView; import android.app.Activity; public class MainActivity extends Activity { private ListView myListView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); myListView = (ListView) findViewById(R.id.myListView); myListView.setAdapter(new ArrayAdapter<String>(this, R.layout.list_view, R.id.tv_content, new String[]{"功能1","功能2","功能3"})); } }
该ArrayAdapter局限在于,只能更改文本内容,无法更改图片
效果图:
相关文章推荐
- ListView的Adapter使用 之 初学ArrayAdapter String
- 关于获得ArrayAdapter对象的细节
- Android开发适配器系列:AutoCompleteTextView和MultiAutoCompleteTextView
- 【adpter】Android ArrayAdapter的使用
- Android常用适配器分析(如何制作简易Launcher)
- ListView_ArrayAdapter
- android中的Adapter使用
- ListView和性能
- 35-Adapter,安卓中数据和视图的桥梁,ArrayAdapter
- Android常用复杂控件使用(二)--ListView
- 2014-2-9AdapterView及其子类1!
- Android ListView详解
- ListView的使用详解
- Android中关于Adapter的使用(上)ArrayAdapter
- Android中关于Adapter的使用(再上)ArrayAdapter
- Android 之 ListView使用ArrayAdapter展示列表
- Android:ListView、ArrayAdapter、ListView属性、获取listview行对象、滚动滑动
- Android Spinner适配器放入list配置的使用
- android--------listview之适配器
- Android零基础入门第40节:自定义ArrayAdapter