0
我想在標籤選擇打開新的一頁...... 當我啓動項目就突然死機推出新的一頁......Tabhost通過意向
這裏是源... (日誌錯誤是您的內容必須具有tabshost其id屬性是R.id.tabhost)
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);
請張貼logcat的 –
看到http://stackoverflow.com/questions/3272500/android-exception-did-you-forget-to-call-public-void-setup-localactivitymanag –