내 탭을 표시하는 데 사용자 정의 TabWidget을 사용하고 있습니다. 프로그램을 처음 실행하면 탭이 멋지게 작동합니다. 모든 것이 아름답게 보입니다. 그러나 프로그램을 다시로드하고 logcat에 따라 onResume() 메서드가 내 Tab Widget에 호출되면 TabWidget은 위젯의 위쪽 절반 만 표시합니다. 내 TabWidget에 대한 XML은 다음과 같습니다.Tab 위젯이 올바르게 표시되지 않습니다 onResume()
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@android:id/tabs"/>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="55dp"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</TabHost>
꽤 평범한 바닐라 재료입니다. layout_height를 변경해도 도움이되지 않습니다.
현재 내 TabWidget.java에서 onResume을 구현하지 않습니다. 그러나 어쨌든 코드를 heres.
public class TabWidget extends TabActivity {
private TabHost mTabHost;
private void setupTabHost() {
mTabHost = (TabHost) findViewById(android.R.id.tabhost);
mTabHost.setup();
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.tabs);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost); // The
// activity
// TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
setupTabHost();
// mTabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);
// Dealer tab
Intent intentDealer = new Intent().setClass(this, DealerActivity.class);
int iconDealer = (R.drawable.ic_tab_dealer);
setupTab("Dealer", intentDealer, iconDealer);
// Department tab
Intent intentDept = new Intent().setClass(this, DeptActivity.class);
int iconDept = R.drawable.ic_tab_dept;
setupTab("Departments", intentDept, iconDept);
// PostBoard Activity
Intent intentBoard = new Intent().setClass(this, BoardActivity.class);
int iconBoard = R.drawable.ic_tab_board;
setupTab("Postboard", intentBoard, iconBoard);
// Social Network connection
// Check first to see if there are Social Network links if not don't
// show tab.
if (Startup.msMain.locations[Startup.nChosenLocation].social_media_feeds.length == 0) {
} else {
Intent intentSocial = new Intent().setClass(this,
SocialActivity.class);
int iconSocial = R.drawable.ic_tab_social;
setupTab("Social Media", intentSocial, iconSocial);
}
// Links Activity
Intent intentLinks = new Intent().setClass(this, LinksActivity.class);
int iconLinks = R.drawable.ic_tab_link;
setupTab("Links", intentLinks, iconLinks);
// set startup tab
tabHost.setCurrentTab(0);
}
private void setupTab(final String tag, Intent intent, int img) {
View tabview = createTabView(mTabHost.getContext(), tag, img);
TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview)
.setContent(intent);
mTabHost.addTab(setContent);
}
private static View createTabView(final Context context, final String text,
int img) {
View view = LayoutInflater.from(context)
.inflate(R.layout.tabs_bg, null);
TextView tv = (TextView) view.findViewById(R.id.tabsText);
tv.setText(text);
ImageView icon = (ImageView) view.findViewById(R.id.tabsIcon);
icon.setBackgroundDrawable(context.getResources().getDrawable(img));
return view;
}
}
오류가 표시되면 여기에 내 logcat이 있습니다.
12-28 10:10:00.963: I/ActivityManager(1305): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.zocalolabs.demo/.SplashScreen } from pid 1470
12-28 10:10:01.034: W/InputManagerService(1305): Starting input on non-focused client [email protected] (uid=10001 pid=1470)
12-28 10:10:01.073: I/ActivityManager(1305): Resumed Activity: com.zocalolabs.demo/.TabWidget totalTime: 110 ms
다시에서 onCreate 방법으로 강제하여 활동을 죽일) (onResume() 또는 onPause에 다시 그리기 내 위젯 활동을 강제에 전체에 강제 할 수있는 방법이 있나요? 아니면이 문제를 공격 할 다른 방법이 있습니까? 통찰력을 가져 주셔서 감사합니다!
그래서 내 자신의 질문에 대답하기위한 점수를 얻지 못했지만 범인은 사실 – Rymnel
인 것으로 판명되었습니다. 자신의 문제에 대한 대답을 찾으면 실제로 자신의 질문에 대답 한 다음 그것을 선택하는 것이 좋습니다. 정답으로 그것에 대해 부끄러워하지 마십시오! 그렇게하면 누군가가 당신의 질문/답변을 찾으면 도움을 줄 수 있고 당신에게 신용을 줄 수 있습니다. http://meta.stackexchange.com/questions/12513/should-i-not-answer-my-own-questions – Aurora
감사합니다. 나는 먼저 가서 대답으로 옮겼다. – Rymnel