Android文件资源管理器使用ListView,缩略图带有multiple_selection(由行上的long_press切换形式为single_selection)

时间:2012-04-24 14:52:42

标签: android listview explorer thumbnails multipleselection

我有一个使用ListView(图标+文本)的文件管理器..仅用于照片(jpg)我想显示预览而不是默认图标..比如es文件浏览器或类似... < / p>

我希望通过长按listview上的一行来将表单single_selection listview ..切换到multiple_selection ..就像在android消息系统应用程序上发生的那样...通过所选行上的highlightes ...没有checbox ..

我的实际情况:

我的ListView为每行使用RelativeLayout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="60dip"
        android:padding="5dip">
        <ImageView
                android:id="@+id/fd_Icon"
                android:layout_width="50dip"
                android:layout_height="50dip"
        >
        </ImageView>
        <TextView
                android:text="Nome"
                android:layout_marginLeft="5dip"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:id="@+id/fd_Text"
                android:layout_toRightOf="@+id/fd_Icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"></TextView>
</RelativeLayout>

我有类FileDirRow

public class FileDirRow {
        private String file_dir_text;
        private int file_dir_icon;
        public FileDirRow( int file_dir_icon , String file_dir_text ) {
                super();
                this.file_dir_icon = file_dir_icon;
                this.file_dir_text = file_dir_text;
        }
        public String getFileDirText() {
                return file_dir_text;
        }
        public int getFileDirIcon() {
                return file_dir_icon;
        }
}

我像这样填写列表视图 ..........

//arrayItemT contains all files and directories of the current path
    ArrayList<FileDirRow> lista_file_dir =new ArrayList<FileDirRow>();

    for(int i=0;i<arrayItemT.size();i++){
        if (arrayItemT.get(i).endsWith("/"))
            lista_file_dir.add(new FileDirRow(R.drawable.folder, arrayItemT.get(i)));
        else
-----------------------------------------------------------------------------
        //if it's a photo add thumbnails or if it's a generic file...
            lista_file_dir.add(new FileDirRow(R.drawable.file, arrayItemT.get(i)));
-----------------------------------------------------------------------------
    }

    //popolate list
    ArrayList<HashMap<String, Object>> data=new ArrayList<HashMap<String,Object>>();

    for(int i=0;i<arrayItemT.size();i++){
         FileDirRow p= lista_file_dir.get(i);

            HashMap<String,Object> rowMap=new HashMap<String, Object>();//create value map

            rowMap.put("image", p.getFileDirIcon()); //for image key,image res
            rowMap.put("name", p.getFileDirText()); //for name key,l'informazine sul nome
            data.add(rowMap);  //add value map to data source
            }
    String[] from={"image","name"}; //from value under this key
    int[] to={R.id.fd_Icon,R.id.fd_Text};//to views id

    //create adapter 
    SimpleAdapter adapter=new SimpleAdapter(
                    getApplicationContext(),
                    data,//sorgente dati
                    R.layout.icon_row, //layout
                    from,
                    to);

    //use adapter
    ((ListView)findViewById(R.id.FileDirList)).setAdapter

0 个答案:

没有答案