android可扩展列表视图

| 我正在使用展开式列表,但我想知道用户单击哪个项目的位置 我已经使用过onitemclick,但是它没有向我显示味精。 我在做什么错?
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());
    }
    
已邀请:
        尝试此操作以在单击孩子时进行处理:
exlv1.setOnChildClickListener(new OnChildClickListener() {
    public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
            int childPosition, long id) {

    }
};
    

要回复问题请先登录注册