Hello,

I have a listview that shows files in a specified folder which works.
But what I can't figure out is in the onListItemClick method. How can
I get the name of the selected file in the ListView from the
ArrayAdapter instead of the position or id?

Any suggestion?

public void updateFileList() {
                File home = new File(FILE_PATH);
                if (home.listFiles().length > 0) {
                        for (File file : home.listFiles()) {
                                if (accept(path, file.getName()) == true) {
                                        files.add(file.getName());
                                        }
                        }
                        ArrayAdapter<String> fileList = new 
ArrayAdapter<String>(this,
R.layout.list_items, files);
                        setListAdapter(fileList);
                }
        }

        @Override
    protected void onListItemClick(ListView l, View v, int position,
long id) {
                super.onListItemClick(l, v, position, id);
        try{
                File f = new File(Environment.getExternalStorageDirectory()+"/
Folder"+"?????????????????????????");
                FileInputStream fileIS = new FileInputStream(f);
                BufferedReader buf = new BufferedReader(new
InputStreamReader(fileIS));
                String readString = new String();
                readString = buf.readLine();

                TextView tv = new TextView(this);
                tv.setText(readString);
                setContentView(tv);

        } catch (FileNotFoundException e) {
                e.printStackTrace();
        } catch (IOException e){
                e.printStackTrace();
        }

    }

Cheers

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to