【发布时间】:2014-02-25 09:39:23
【问题描述】:
我正在尝试在选项卡选择上打开新页面... 当我启动项目时它突然崩溃...
这里是源... (Log Error是你的内容必须有一个id属性为R.id.tabhost的tabshost)
public class AddFriends_Activity extends TabActivity implements SwipeInterface {
TabHost mTabHost;
Resources res = getResources();
Intent i = new Intent(this,Added_Friends.class);
Intent j = new Intent(this,Friend_List.class);
TabHost mTabHst = getTabHost();
mTabHst.addTab(mTabHst.newTabSpec("tab_test1").setIndicator("Add Frinds",res.getDrawable(R.drawable.add1))
.setContent(i));
mTabHst.addTab(mTabHst.newTabSpec("tab_test2").setIndicator("Friend List",res.getDrawable(R.drawable.add1))
.setContent(j));
int tabCount = mTabHst.getTabWidget().getTabCount();
for (int r = 0; r < tabCount; r++) {
final View view = mTabHst.getTabWidget().getChildTabViewAt(r);
if ( view != null ) {
// reduce height of the tab
view.getLayoutParams().height *= 0.90;
// get title text view
final View textView = view.findViewById(android.R.id.title);
if ( textView instanceof TextView ) {
((TextView) textView).setGravity(Gravity.BOTTOM);
((TextView) textView).setTextSize((float) 12);
((TextView) textView).setTextColor(android.graphics.Color.WHITE);
((TextView) textView).setSingleLine(false);
// explicitly set layout parameters
textView.getLayoutParams().height = ViewGroup.LayoutParams.FILL_PARENT;
textView.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
}
}
}
mTabHst.setCurrentTab(0);
【问题讨论】:
标签: android android-intent android-tabhost