2011-09-01 10 views
0

안녕 얘들 아, 아마 일부 소녀, 레이아웃 개체를 쌓을 수 있습니다. 그래서 하나의 객체가 다른 객체 위에있다? 내 문제는, 내가 tabhost있어 tabhostow tabview 아래에있는 textview 있어요.서로 다른 레이아웃 오브젝트를 스택하는 방법은 무엇입니까?

나는 탭 호스트 탭을 보이지 않게 만들었지 만, 내 tablrow를 텍스트 뷰어로 숨겼는데, 어떻게 그것을 infront 할 수 있습니까?

여기에 사전에

<?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" 
     android:weightSum="1"> 
    <RelativeLayout 
     android:orientation="vertical" 
     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_weight="1" /> 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom = "@android:id/tabcontent" 
      android:visibility="invisible"/> 

     <TableRow 
      android:id="@+id/ADFilterOverview" 
      android:layout_height="wrap_content" 
      android:onClick="onClickADConfig" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignTop="@android:id/tabs" 
      android:layout_width="match_parent"> 

      <TextView 
       android:text="@string/newadfilter" 
       style="@style/NormalFont" 
       android:layout_gravity="bottom|left"> 
      </TextView> 
     </TableRow> 
    </RelativeLayout> 
</TabHost> 

들으

안부 사파리

더 나은 이해를위한 몇 가지 자세한 내용은 Layout.xml에게 있습니다 : 내 활동의 이후 내 코드

다음과 같이 보입니다.

package de.retowaelchli.filterit; 

    import android.app.TabActivity; 
    import android.os.Bundle; 
    import android.widget.TabHost; 
    import android.content.Intent; 

    public class StatsActivity extends TabActivity { 
     /** Called when the activity is first created. */ 
     @Override 
     public void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.stats); 
      TabHost tabHost = getTabHost();  

      tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("whatever").setContent(new Intent(this, SFilterStatsActivity.class))); 
      tabHost.setCurrentTab(1); 

     } 

    /** Verweise auf die anderen Seiten **/ 
public void onClickADConfig(View view){ 
    final Intent i = new Intent(this, ADFilterConfigActivity.class); 
    startActivity(i); } 


    } 

내 Tabhost에서 링크 된 클래스는 다음과 같은 예를 들어 본다 : 당신이 볼, 난 내 ListActivity에서 가득 그것은 하나 개의 탭이있는 TabHost를 가지고 그래서

package de.retowaelchli.filterit; 

import android.app.ListActivity; 
import android.os.Bundle; 
import android.widget.ArrayAdapter; 


public class ADFilterStatsActivity extends ListActivity { 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mListContent)); 
    } 

    private static String[] mListContent={"Item 1", "Item 2", "Item 3","Item 1", "Item 2", "Item 3","Item 1", "Item 2", "Item 3","Item 1", "Item 2", "Item 3"}; 
} 

에서, tabhost가 숨겨져 야 (보이지 않는),이 숨겨진 탭 위에 tablerow 표시되어야합니다. 그래서 나는 그것을 클릭하여 다른 클래스에 갈 수 있습니다. 나는이 너희들 도움이되기를 바랍니다 ...

Egon

그리고 여기가

<?xml version="1.0" encoding="utf-8"?> 


<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabcontent" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    > 



     <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:orientation="vertical" 
     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_weight="1" /> 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom = "@android:id/tabcontent" 
      android:visibility="invisible"/> 
     <TableRow android:layout_height="wrap_content" android:id="@+id/ADFilterOverview" android:layout_width="match_parent" android:onClick="onClickADConfig" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true"> 
      <TextView android:layout_gravity="bottom|left" android:text="@string/newadfilter" style="@style/NormalFont"></TextView> 
     </TableRow> 
     </RelativeLayout> 
     </TabHost> 


    </FrameLayout> 
+0

왜 당신은 당신의 TabHost 보이지 않는가? – user370305

+0

나는 하나의 탭만 가지고 있으며, 항상 탭으로 구성되어 있고 데이터베이스에서 채워지는 ListActivity의 내용으로 채워져있다. 나는이 Tabhost에서 나중에 보여지는 데이터베이스에 대한 내용을 설정할 수있는 다음 활동으로 Tablerow가 필요합니다. =) 항상 Tab을 사용했기 때문에 – safari

+0

을 이해하기를 바랍니다. 왜 TabHost를 사용합니까? –

답변

1

부모보기를 보이지 않게하면 하위보기도 자동으로 보이지 않게됩니다. 이 시나리오에서는 새 탭의 다른 레이아웃을 정의해야합니다.

이것이 올바르지 않으면 수정하거나 제안하십시오. 고맙습니다

EDIT : 귀하의 XML 코드에서 tabhost는 parentview 및 tablerow이고 textview는 그 childview입니다.

0

내가 문제가 당신이 될 수있는 tabwidget을 설정하는 것이 믿습니다 솔루션을 인 해결책 THX를 FOUND alignParentBottom 다음 tabRow를 설정하여 tabwidget에 aligntop을 지정하십시오. 따라서 그것은 보이지 않습니다. 탭 위젯을 보이지 않게 만드는 것은 숨길 수 있지만 자리 표시자는 여전히 있습니다.

+0

그래서 내가 바꿔야하는 것은 무엇입니까? – safari

2

View을 Z 축 방향으로 겹쳐 놓으려면 FrameLayout을 사용할 수 있습니다. 이 도구를 사용하면 배경에 View을 배치하고 그 위에 다른보기를 배치 할 수 있습니다. 정말 강력하고 사용하기 쉽기 때문에 시험해보아야합니다. 희망이 도움이됩니다.

+0

Thx 당신의 도움이 있습니다. FrameLayout을 가지고 있는데 어떻게 백그라운드로 얻을 수 있습니까? – safari

+0

@safari, FrameLayout 안에 배치 된 첫 번째보기는 항상 배경보기, 모든 다른 포 그라운드에 있습니다. 물론 목표를 달성하기 위해 중첩 된 레이아웃을 만들 수 있습니다. – Egor

+0

흠, 나는 여전히 이것을하려고합니다 :(), 레이아웃 모양을 어떻게해야합니까? – safari

관련 문제