Android: Multiple choice select list - Check the checkbox only when the checkbox is seleted and not on text-view
<p>I'm ceating a multiple_choice List View which shows names of Directories.
Since it is multiple-choice select, each item contains a textview and a checkbox.
By default when I click on any item, the checkbox gets selected/deselected.
This is not the functionality I want.
Since, I'm showing names of directories, I want when the user clicks on the item, instead of the checkbox getting selected, a new list should be displayed containing the name of sub-folder of that directory.</p>

<p>In simple terms, when the textview of the item is selected a new list should get displayed &amp; when the the check box is selected then only the check box should be checked/unchecked.</p>

<p>Below, is my code till now:</p>

<pre><code>public class DirectoryListing extends Activity implements OnItemClickListener {

    ListView dirlv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.directorylisting);
        try {
            ArrayList&lt;String&gt; dirList = new ArrayList&lt;String&gt;();
            dirList = getAllDirList();
            ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
                    android.R.layout.simple_list_item_multiple_choice,
                    android.R.id.text1, dirList);
            dirlv = (ListView) findViewById(R.id.lvDirList);
            dirlv.setAdapter(adapter);
            dirlv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
            dirlv.setOnItemClickListener(this);

        } catch (Exception e) {
            Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
        }

    }

    private ArrayList&lt;String&gt; getAllDirList() {
        ArrayList&lt;String&gt; result = new ArrayList&lt;String&gt;();
        File home = new File("/");
        File[] files = home.listFiles();
        for (File file : files) {
            if (file.isDirectory()) {
                result.add(file.getName());
            }
        }
        return result;
    }

    @Override
    public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,
            long id) {
        try {
            TextView tv = (TextView) view;
            //TODO
        } catch (Exception e) {
            Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
        }
    }

}
</code></pre>
