user interface - Android Fixed Tabs on a Processing PApplet -
i developing android app based on processing
i show 2 fixed tabs content when menu button pressed.
tab1 contain settings , maybe button
tab2 should have listview show list of presets. trying create 2 textviews sake of simplicity.
trying approach of ketai library ketailist
there's inner class extends tabhost inside papplet class extended application:
public class myprocessingapp extends papplet { public void setup() { } public void draw() { } public void keypressed() { if (key == coded) { if (keycode == keyevent.keycode_menu) { tabhost th = new gbtab(this); } } } public class gbtab extends tabhost { private papplet parent; tabhost self; tabwidget tab1, tab2; linearlayout layout; public gbtab(papplet _parent) { super(_parent.getapplicationcontext()); parent = _parent; init(); } public void init() { println("gbtab init"); self = this; layout = new linearlayout(parent); tabspec settingsspec = self.newtabspec("settings").setcontent( new tabcontentfactory() { public view createtabcontent(string tag) { textview tv = new textview(parent); tv.settext("settings!"); return tv; } } ) .setindicator("settings"); self.addtab(settingsspec); tabspec presetsspec = self.newtabspec("presets").setcontent( new tabcontentfactory() { public view createtabcontent(string tag) { textview tv = new textview(parent); tv.settext("presets!"); return tv; } } ) .setindicator("presets"); self.addtab(presetsspec); self.setcurrenttab(0); parent.runonuithread(new runnable() { public void run() { parent.addcontentview(self, new viewgroup.layoutparams( viewgroup.layoutparams.fill_parent, viewgroup.layoutparams.fill_parent)); } } ); } } }
this code gives nullpointerexception when adding tab tabhost.
self.addtab(settingsspec);
since self null.
valid approach?
thank you
how second answer (24 votes) in this? says since not using tabactivity need call self.setup(); before adding tabs
Comments
Post a Comment