2012-01-06 2 views
1

image 및 listview가있는 레이아웃이 있습니다. 그 아래에 탭을 추가해야합니다. 탭 위젯을 사용하면 첫 번째 탭이 강조 표시되고 해당 탭 활동 결과가 탭 아래에 표시됩니다. 그래서 첫 번째 탭의 활동을 멈춰야합니다. 탭을 클릭 할 때 활동 만 호출하면 다른 화면으로 이동해야합니다.기본적으로 탭을 강조 표시하지 않음

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <ImageView android:id="@+id/imageView1" 
    android:background="@drawable/banner" 
    android:layout_width="323dp" 
    android:layout_height="100dp"></ImageView> 
    <RelativeLayout android:id="@+id/relativeLayout1" android:layout_height="28dp" android:layout_width="fill_parent"> 
     <ImageView android:layout_alignParentTop="true" android:onClick="mapfunction" android:layout_width="wrap_content" android:id="@+id/imageView2" android:src="@drawable/map1" android:layout_height="100dp" android:layout_marginRight="10dp" android:layout_toLeftOf="@+id/textView1"></ImageView> 
     <ImageView android:layout_width="wrap_content" android:id="@+id/imageView3" android:src="@drawable/listtab" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginRight="10dp" android:layout_toLeftOf="@+id/textView2"></ImageView> 
     <TextView android:id="@+id/textView2" android:text="LIST" android:layout_width="wrap_content" android:textStyle="bold" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toLeftOf="@+id/imageView2" android:layout_marginRight="14dp"></TextView> 
     <TextView android:id="@+id/textView1" android:text="MAP" android:layout_width="wrap_content" android:textStyle="bold" android:layout_height="wrap_content" android:layout_alignBottom="@+id/imageView3" android:layout_alignParentRight="true" android:layout_marginRight="31dp"></TextView> 
    </RelativeLayout> 
    <ListView android:id="@id/ListView01" android:layout_width="fill_parent" android:layout_height="253dp"></ListView> 
    <TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" android:layout_height="44dp"> 
      <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" android:layout_height="34dp"/> 
     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:padding="5dp" android:layout_height="fill_parent"/> 
</TabHost> 
</LinearLayout> 

는 아래의 탭을 표시하는 내 활동 코드 :

다음은 내 XML 코드입니다. 현재 탭을 사용하면 단순히 2 그래픽 동일하게 설정할 수 있습니다 다음 강조 싶지 않을 경우

Resources res = getResources(); // Resource object to get Drawables 
     TabHost tabHost = getTabHost(); // The activity TabHost 
     TabHost.TabSpec spec; // Resusable TabSpec for each tab 
     Intent intent; // Reusable Intent for each tab 
     intent = new Intent().setClass(this, Contacts.class); 

     // Initialize a TabSpec for each tab and add it to the TabHost 
     spec = tabHost.newTabSpec("places").setIndicator("PLACES", 
          res.getDrawable(R.drawable.places)) 
         .setContent(intent); 
     tabHost.addTab(spec); 

     // Do the same for the other tabs 
     intent = new Intent().setClass(this, Contacts.class); 
     spec = tabHost.newTabSpec("camera").setIndicator("CAMERA", 
          res.getDrawable(R.drawable.camera)) 
         .setContent(intent); 
     tabHost.addTab(spec); 
     tabHost.setCurrentTab(0); 
+0

무엇을하고 있으며 무엇을하고 싶습니까? 그것은 x를하고 있지만 y를하고 싶습니다. 나는 당신의 질문에서 그것을 파싱 할 수 없다. –

+0

제 질문은 간단합니다. 기본적으로 탭을 강조 표시하고 싶지 않습니다. – Vamshi

+0

강조 표시를하면 기본적으로 페이지가 표시되지 않아야한다는 것을 의미합니까? 또는 오렌지색 (또는 피부색이 무엇이든간에)으로 채색되어 있습니까? –

답변

0

는 단순히 활동

tabHost.setCurrentTab(0);

+0

나중에 사용해 보았습니다. – Vamshi

1

에서 현재 탭을 설정 해달라고.

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <!-- When selected, use grey --> 
    <item android:drawable="@drawable/ic_tab_files_white" 
      android:state_selected="true" /> 
    <!-- When not selected, use white--> 
    <item android:drawable="@drawable/ic_tab_files_white" /> 
</selector> 
+0

다음과 같이 샘플 코드를 제공합니까? 나는 안드로이드를 처음 사용하기 때문에 이것에 대한 지식이 없다. – Vamshi

+0

코드 관련이 없다. @drawable을 일반 그래픽과 선택한 그래픽 모두에 대해 "@ drawable/ic_tab_files_white"로 설정하면됩니다. –

+0

그래, 그럴거야,하지만 어떻게 그 탭의 활동을 멈출 수 – Vamshi

관련 문제