Custom tab in android - getting error while using "setIndicator" -


i trying create custom tab in android app , got sample codes code showing errors in setindicator method...here code

error getting - method setindicator(charsequence) in type tabhost.tabspec not applicable arguments (textview)

package com.myapp;  import android.app.activity; import android.graphics.color; import android.os.bundle; import android.view.gravity; import android.view.view; import android.widget.framelayout; import android.widget.linearlayout; import android.widget.tabhost; import android.widget.tabwidget; import android.widget.textview; import android.widget.linearlayout.layoutparams; import android.widget.tabhost.tabcontentfactory; import android.widget.tabhost.tabspec;  //custom tabs public class myactivity extends activity {  int tabheight = 40;  @override public void oncreate(bundle savedinstancestate) {  super.oncreate(savedinstancestate); linearlayout main = new linearlayout(this); main.setorientation(linearlayout.vertical); setcontentview(main);  tabhost tabs = new tabhost(this); tabs.setid(android.r.id.tabhost); main.addview(tabs);  tabwidget tabwidget = new tabwidget(this); tabwidget.setid(android.r.id.tabs); tabs.addview(tabwidget);  framelayout tabcontent = new framelayout(this); tabcontent.setid(android.r.id.tabcontent); tabcontent.setpadding(0, tabheight, 0, 0); tabs.addview(tabcontent);  textview content = new textview(this); content.settext("this frame content"); content.setid(100); tabs.setup();  tabspec tspec1 = tabs.newtabspec("tab1"); tspec1.setindicator(maketabindicator("one")); tspec1.setcontent(new preexistingviewfactory(content)); tabs.addtab(tspec1);  tabspec tspec2 = tabs.newtabspec("tab2"); tspec2.setindicator(maketabindicator("two")); tspec2.setcontent(new preexistingviewfactory(content)); tabs.addtab(tspec2);  tabspec tspec3 = tabs.newtabspec("tab3"); tspec3.setindicator(maketabindicator("three")); tspec3.setcontent(new preexistingviewfactory(content)); tabs.addtab(tspec3);  }  private textview maketabindicator(string text){  textview tabview = new textview(this); layoutparams lp3 = new layoutparams(layoutparams.wrap_content, tabheight, 1); lp3.setmargins(1, 0, 1, 0); tabview.setlayoutparams(lp3); tabview.settext(text); tabview.settextcolor(color.white); tabview.setgravity(gravity.center_horizontal|gravity.center_vertical); tabview.setbackgrounddrawable( getresources().getdrawable(r.drawable.tab_indicator)); tabview.setpadding(13, 0, 13, 0); return tabview;  }    class preexistingviewfactory implements tabcontentfactory{  private final view preexisting; protected preexistingviewfactory(view view){ preexisting = view; }  public view createtabcontent(string tag) { return preexisting; }  }  } 

anybody pls me fix issue ...

thanx in advance .. kris

unfortunately method setindicator(view view) works android 1.6 , (version 4). if supporting android 1.5 (version 3) can use string/charsequence indicator using setindicator(charsequence label).

see reference: http://developer.android.com/reference/android/widget/tabhost.tabspec.html#setindicator

notice method setindicator(view view) "since: api level 4"


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -