2017-03-08 77 views

回答

0
public void onListItemClick(ListView l, View v, int position, long id) { 

你可能需要一個類Filechooser在那裏你可以發送意圖

Intent i = new Intent(this, FileChooser.class); 
0

你可以試試這個:

// Instanciating an array list 
ArrayList<String> your_array_list = new ArrayList<String>(); 
//add file names  

// This is the array adapter, it takes the context of the activity as a 
// first parameter, the type of list view as a second parameter and your 
// array as a third parameter. 
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(
     this, 
     android.R.layout.simple_list_item_1, 
     your_array_list); 

listview.setAdapter(arrayAdapter); 

listview.setOnItemClickListener(new AdapterView.OnItemClickListener() 
{ 
    @Override 
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) 
    { 
     String file_name = your_array_list.get(position); 
     File file = new File(dirPath, file_name); 
     //do stuff 
    }   
});