I have an android app that extends a MapActivity, so I can't extend TabActivity. I am inflating the content of the tabs dynamically, and everything looks good.
The problem that I'm running in to is that I get a NullPointerException when trying to bind event listeners to the views that were inflated into a tab past the first 开发者_运维问答tab.
Example:
myButtonInTab2 = (Button)this.findViewById(R.id.mybuttonintab2);
myButtonInTab2.setOnClickListener(new OnClickListener(){
public void(View v){
///blah blah blah
}
});
If you are "inflating the content of the tabs dynamically", you should be calling findViewById()
on the result of the inflate()
call, for any widgets in that tab.
精彩评论