展会信息港展会大全

Android中ListView与ArrayAdapter配合使用
来源:互联网   发布日期:2015-11-25 22:50:30   浏览:1531次  

导读:1. [代码]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=fil......

1. [代码]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>

2. [代码][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);

}

赞助本站

人工智能实验室

相关热词: ListView ArrayAdapter

AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港