null pointer exception in textview of setcontent
- by kitokid
I am getting the java.lang.NullPointerException on createTabContent for the following code. There are two tabspecs. When I called and set the tab , changed the tabs for the first time it is ok. But when i called again while I am on the second tab, its hit the null pointer exception for line : NoStudentText.setVisibility(View.VISIBLE);
I will show No Student Text if there is no data for the student list. It shows the text for the first time call. But If I do second time call to that tab, got the error.
tspecStudent.setContent(new TabContentFactory() {
public View createTabContent(String arg0) {
if(listStudent != null && listStudent .size() > 0) {
//show the student list
} else {
TextView noStudentText = (TextView)findViewById(R.id.NoStudentText);
noStudentText.setVisibility(View.VISIBLE);
return noStudentText;
}
}
});