2012-01-10 99 views
0

我有数据(蓝牙设备)的一个ArrayList,我想列出清单的设备, 为此,我已经取得了自定义视图(item.xml):填充列表视图与自定义布局项目

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" > 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/images" /> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="TextView" 
     android:layout_margin="10dip" /> 

</LinearLayout> 

组成的ImageView的和一个TextView的,这样我就可以把设备和INT列表中的标准图像的名称,这里是main.xml中的文件:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <ProgressBar 
     android:id="@+id/progressBar1" 
     style="?android:attr/progressBarStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

</LinearLayout> 

进度条用于扫描在活动开始时进行操作。

任何帮助,将不胜感激,谢谢

回答

1

一个ListView可以支持不同的布局(意见),并可以动态建立。这是通过一个自定义适配器完成的。

0

你需要列表视图来保存这些数据在列表中。在你的主布局中我不能看到任何列表视图。以列表视图后,您需要定义适配器为ListView和在你的列表视图中使用该适配器。

希望这将帮助你

相关问题