null pointer exception in textview of setcontent
Posted
by
kitokid
on Stack Overflow
See other posts from Stack Overflow
or by kitokid
Published on 2012-11-26T04:00:05Z
Indexed on
2012/11/26
5:04 UTC
Read the original article
Hit count: 149
android
|android-layout
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;
}
}
});
© Stack Overflow or respective owner