Android Tab Menu not working
I'm trying to make a MenuTab with android but I have a lot of problems.
Here's my code
tabHost = (TabHost) A.findViewById(R.id.tabHost);
tabHost.setup();
TabSpec spec1 = tabHost.newTabSpec("tab_news");
spec1.setIndicator(
"", //Load news titlte
A.getResources().getDrawable(R.drawable.icon_menu_news) //Load icon
);
spec1.setContent(R.id.tab_news);
tabHost.addTab(spec1);
First question, why if I put "title" inside indicator I don't see the image?
Well now I want to create a new activity when this tab is selected.
TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
firstTabSpec.setIndicator("First Tab Name").setContent(new
Intent(A,Test.class));
This example doesn't work... I get this error
09-15 23:19:26.861: E/AndroidRuntime(14938): java.lang.RuntimeException:
Unable to start activity
ComponentInfo{com.workactivity/com.workactivity.MainActivity}:
java.lang.IllegalStateException: Did you forget to call 'public void
setup(LocalActivityManager activityGroup)'?
I try to google about setup but I get no matchs...
I follow this tutorial:
http://www.androidpeople.com/android-tabhost-tutorial-part-1 And this one:
http://android-pro.blogspot.com.es/2010/08/tabbed-applications-in-android.html
Thanks for all :)
No comments:
Post a Comment