0
我使用擴展列表,但我想知道哪些項目是由用戶
點擊我已經使用onitemclick但它不告訴我味精位置..
我在做什麼錯?Android的可擴展列表視圖
public void funName(){
File ringtones_directory = new File(DIRECTORY);
if (!ringtones_directory.exists()) {
AlertDialog.Builder ad = new AlertDialog.Builder(
FindFilesByType.this);
ad.setTitle("Directory Not Found");
ad.setMessage("Sorry! The ringtones directory doesn't exist.");
ad.setPositiveButton("OK", null);
ad.show();
hasErrors = true;
}
if (!ringtones_directory.canRead()) {
AlertDialog.Builder ad = new AlertDialog.Builder(
FindFilesByType.this);
ad.setTitle("Permissions");
ad
.setMessage("Sorry! You don't have permission to list the files in that folder");
ad.setPositiveButton("OK", null);
ad.show();
hasErrors = true;
} else {
Ringtones = FindFiles(false);
if (Ringtones.size() < 1) {
AlertDialog.Builder ad = new AlertDialog.Builder(
FindFilesByType.this);
ad.setTitle("Permissions");
ad.setMessage("Sorry! No ringtones exists in " + DIRECTORY
+ ".");
ad.setPositiveButton("OK", null);
ad.show();
Log.e(LOG_TAG, "No ringtones were found.");
hasErrors = true;
}
}
try {
if (!hasErrors) {
// refreshList();
// this.lv1.setAdapter(new ArrayAdapter<String>(
// FindFilesByType.this, android.R.layout.test_list_item,
// Ringtones));
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
FindFilesByType.this, android.R.layout.test_list_item,
Ringtones);
ArrayList<String> GrouppList = new ArrayList<String>();
GrouppList.addAll(Ringtones);
ArrayList<ArrayList<Color>> colors = new ArrayList<ArrayList<Color>>();
for(int i=0;i<=Ringtones.size();i++){
ArrayList<Color> color = new ArrayList<Color>();
color = new ArrayList<Color>();
color.add(new Color(" ", "", true));
colors.add(color);}
expListAdapter = new ColorAdapter(this, GrouppList, colors);
// setListAdapter(expListAdapter);
exlv1=(ExpandableListView) findViewById(R.id.expandableListView1);
this.exlv1.setAdapter(expListAdapter);
//exlv1.setAdapter(expListAdapter);
this.exlv1.setOnItemClickListener(new OnItemClickListener() {
//THIS METHOD NOT WORKING FOR ME
@Override
public void onItemClick(AdapterView<?> aview, View v,
int position, long id) {
Toast.makeText(FindFilesByType.this, "position "+position, Toast.LENGTH_LONG).show();//THIS DOESNOT WORKING
// TODO Auto-generated method stub
}
});
}
} catch (Exception e) {
Toast.makeText(this, "Error " + e.toString(), Toast.LENGTH_LONG)
.show();
Log.i(LOG_TAG, e.toString());
}