java - How do I programattically create a Tab with EditText in it? -


my app's text editor lets user open , edit files, want open file new tab in tabhost multiple files can open. how add edittext newly created tab? tried in oncreate()

tabhost tabhost=(tabhost)findviewbyid(r.id.tabhost);         tabhost.setup();         edittext editor = new edittext(this);         tabspec spec1=tabhost.newtabspec("tab 1");         spec1.setcontent(editor.getid());         spec1.setindicator("tab 1"); 

i assume problem `spec1.setcontent(editor.getid());

you try set id (which not defined way) layout id. won't work way. try:

tabhost tabhost=(tabhost)findviewbyid(r.id.tabhost);         tabhost.setup();         edittext editor = new edittext(this);         tabspec spec1=tabhost.newtabspec("tab 1");         spec1.setindicator(editor);  

if want. can try:

tabhost tabhost=(tabhost)findviewbyid(r.id.tabhost);             tabhost.setup();             final edittext editor = new edittext(this);             tabspec spec1=tabhost.newtabspec("tab 1");             spec1.setcontent(new tabhost.tabcontentfactory(){                  public view createtabcontent(string tag){                      return editor;                  }              }); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -