현재 탭 호스트가 표시된 응용 프로그램을 개발 중입니다. 탭 호스트의 각 탭은 활동입니다. 자, 이제 텍스트 탭 표시기를 이미지로 대체하는 것입니다. 이 코드는 내 탭 호스트 활동을 구현하는 데 사용한 코드입니다. TabHostActivity :이미지를 Android 탭 호스트에서 탭 표시기로 추가하는 방법은 무엇입니까?
public class TabHostActivity extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tabhost);
TabHost tabHost = (TabHost) findViewById (android.R.id.tabhost);
TabSpec tab1 = tabHost.newTabSpec("First Tab");
TabSpec tab2 = tabHost.newTabSpec("Second Tab");
TabSpec tab3 = tabHost.newTabSpec("Third Tab");
tab1.setIndicator("Tab1");
tab1.setContent(new Intent(this, Tab1Activity.class));
tab1.setContent(new Intent(this, Tab1Activity.class));
tab2.setIndicator("Tab2");
tab2.setContent(new Intent(this, Tab2Activity.class));
tab3.setIndicator("Tab3");
tab3.setContent(new Intent(this, Tab3Activity.class));
tabHost.addTab(tab1);
tabHost.addTab(tab2);
tabHost.addTab(tab3);
}
}
당신이 내 코드에서 볼 수 있듯이, 내 탭 지표로 TAB1, TAB2, tab3에 설정하고, 이것은 이미지
으로이를 대체 할 내
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabhost">
<LinearLayout
android:id="@+id/LinearLayout01"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
</FrameLayout>
</LinearLayout>
</TabHost>
내 대답을 수락 할 수 있습니까? –
절대! 절대적으로! 절대적으로! 절대적으로! – KirbyAbadilla
제발 upvote 날 그리고 그것을 승인 –