ArrayAdapter
来源:互联网 发布:美工绩效考核 编辑:程序博客网 时间:2024/05/16 17:01
activity_main.xml
<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;@Overrideprotected 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局限在于,只能更改文本内容,无法更改图片
效果图:
0 0
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- Arrayadapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- 创建删除DBLINK
- zoj2967 Colorful Rainbows(凸包 排序 栈)
- <Http权威指南 1,2,3>Http概述
- 五大常用算法之四:回溯法
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- ArrayAdapter
- PHP性能优化工具–xhprof安装
- ios UIButton得 几种触发方式
- 五大常用算法之五:分支限界法
- 记录我的旅程
- 使用shc简单加密后的脚本文件恢复
- 寻找最大的k个数
- tomcat7--container
- 2亿个整数中求最大的100万之和