2011-04-03 4 views
0

salut s'il vous plaît aider en fait j'essaie de rendre la vue de la liste comme invisible mais son montrant le listview et gridview à la fois s'il vous plaît aider à résoudre le problème. voici le code.Créer une vue

public void onCreate(Bundle icicle) { 
     super.onCreate(icicle); 
     setContentView(R.layout.main); 
     Gallery gallery = (Gallery) findViewById(R.id.gallery1); 
    lst=(ListView)findViewById(R.id.list); 
    lst.setVisibility(View.INVISIBLE); 
    // ViewManager hi=(ViewManager)getBaseContext().getSystemService(WINDOW_SERVICE); 


     gallery.setAdapter(new ImageAdapter(this));   
     final GridView gridView = (GridView) findViewById(R.id.gridview); 

     mInflater = (LayoutInflater) getSystemService(Activity.LAYOUT_INFLATER_SERVICE); 
     data = new Vector<RowData>(); 
     for(int i=0;i<title.length;i++){ 
     try { 
      rd = new RowData(i,title[i],detail[i]); 
      } catch (ParseException e) { 
       e.printStackTrace(); 
      } 
      data.add(rd); 
      lst.setAdapter(new CustomAdapter(this, R.layout.list,R.id.title,data)); 
     } 

     gridView.setAdapter(new ImageAd(this)); 

     final TabHost tabs=(TabHost)findViewById(R.id.tabhost); 


     tabs.setup(); 

     final TabHost.TabSpec spec=tabs.newTabSpec("buttontab"); 
     final TabHost.TabSpec spec1=tabs.newTabSpec("btn"); 
     spec.setContent(R.id.list); 
     lst.setVisibility(View.INVISIBLE); 
     spec1.setContent(R.id.buttontab); 
     spec.setIndicator("tab1"); 

     spec1.setIndicator("tab1"); 
     tabs.addTab(spec); 
     tabs.setCurrentTab(0); 
     tabs.getTabWidget().getChildAt(0).setLayoutParams(new 
       LinearLayout.LayoutParams(30,30)); 
spec.setIndicator("tab2"); 
     tabs.addTab(spec); 
     tabs.getTabWidget().getChildAt(1).setLayoutParams(new 
       LinearLayout.LayoutParams(30,30)); 
     tabs.setOnTabChangedListener(new OnTabChangeListener(){ 
      @Override 
      public void onTabChanged(String tabId) { 
       if(tabId=="buttontab") 

et voici fichier xml

<?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" 
    > 
    <LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="50px" 
    android:orientation="horizontal"> 
    <Button 
    android:id="@+id/login" 
    android:layout_width="80px" 
    android:layout_height="wrap_content" 
    android:text="Login" 
    /> 
    <TextView 
    android:paddingLeft="80px" 
    android:id="@+id/search" 
    android:layout_width="40px" 
    android:text="Search" 
    android:layout_height="wrap_content" 

    /> 
    <EditText 

    android:layout_width="100px" 
    android:layout_height="wrap_content" 
    /> 
    </LinearLayout> 
    <Gallery 
     android:id="@+id/gallery1" 
     android:layout_width="fill_parent" 
     android:layout_height="50px" /> 

    <TabHost android:id="@+id/tabhost" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <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="fill_parent" 
      android:layout_height="fill_parent" 
      android:paddingTop="62px"> 
      <ListView android:id="@+id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="200px" /> 
      <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      > 


     <GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/gridview" 
    android:layout_width="fill_parent" 
    android:layout_height="200px" 
    android:numColumns="4" 
    android:verticalSpacing="5px" 
    android:horizontalSpacing="5px" 
    android:columnWidth="60dp" 
    android:stretchMode="columnWidth" 
    android:gravity="center" 
/>  
<LinearLayout 
android:orientation="horizontal" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
> 
<Button 
android:id="@+id/buttontab" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:src="@drawable/icon"/> 
<ImageButton 
android:id="@+id/hello1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:src="@drawable/icon"/> 

<ImageButton 
android:id="@+id/hello3" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:src="@drawable/icon"/> 
<ImageButton 
android:id="@+id/hello4" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:src="@drawable/icon"/> 
<ImageView 
android:id="@+id/hello5" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:src="@drawable/icon"/> 

</LinearLayout> 
      </LinearLayout>> 
     </FrameLayout> 
    </TabHost> 
</LinearLayout> 

donc s'il vous plaît aider à faire listview comme invisiblei savent son erreur très peu, mais incapable de résoudre l'erreur

Répondre

0

Essayez View.GONE au lieu de vue Comme vous le faites dans onCreate, vous pouvez le faire dans votre XML:

<ListView 
    android:id="@+id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="200px" 
    android:visibility="gone" 
/>