I have the following code that is pretty easy to understand. I want some particular child of this list not to be clickable.
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this,R.layout.list_item,R.id.module_name_item, testdata);
m_listview.setAdapter(adapter);
Log.i("check","1");
if(sectionAttempts.get(0).equals("0"))
{
m_listview.getChildAt(2).setEnabled(false);
m_listview.getChildAt(3).setEnabled(false);
}
else
{
if(sectionAttempts.get(2).equals("0"))
{
m_listview.getChildAt(3).setEnabled(false);
}
}
I get an error in
m_listview.getChildAt(2).setEnabled(false);
like java.lang.NullpointerException. I tried to find the error and used Log.i ("check", m_listview.getChildCount ()); And it shows 0., so I guess the listview has not been created yet! How is this possible.
What is the problem? Thanx for any help in advance.
source
share