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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -