2
나는 내 애플 리케이션 중 하나에 대한 안드로이드에서 탭 위젯을 사용하려고합니다. 이 탭 위젯에는 두 개의 탭이 있습니다. 나는 다음과 같은 두 가지 배경 이미지를 가지고있다. 사용자가 탭을 클릭하면 이미지가 변경됩니다. 내 상황에서 어떻게 가능할까요? 다음은 XML 파일에 내 코드는안드로이드에서 tabwidget의 이런 상황을 극복하는 방법
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relative_my_student_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:padding="-4dp"
>
<RelativeLayout
android:id="@+id/relative_top"
android:layout_width="fill_parent"
android:layout_height="140dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@drawable/header" >
</RelativeLayout>
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/footer"
android:layout_below="@+id/relative_top" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>
다음 코드는 자바에서입니다
TabHost tabHost = getTabHost();
// Tab for Photos
TabSpec student_list = tabHost.newTabSpec("Photos");
student_list.setIndicator("", getResources().getDrawable(R.drawable.my_student_list_green_line));
Intent photosIntent_intent = new Intent(this, Student_List_Activity.class);
student_list.setContent(photosIntent_intent);
// Tab for Songs
TabSpec add_new_student = tabHost.newTabSpec("Songs");
// setting Title and Icon for the Tab
add_new_student.setIndicator("", getResources().getDrawable(R.drawable.my_student_add_new_student));
Intent add_new_student_intent = new Intent(this, Add_New_Student.class);
add_new_student.setContent(add_new_student_intent);
// Tab for Videos
// Adding all TabSpec to TabHost
tabHost.addTab(student_list); // Adding photos tab
tabHost.addTab(add_new_student); // Adding songs tab
때 다음과 같이 나는 두 이미지를 사용자 c 이러한 이미지는 내가