hi please help actually i m trying to make list view as invisible but its showing the listview and gridview both at one time please help in solving it. here is the code.
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")
and here is xml file
<?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
andro开发者_JS百科id: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>
so please help to make listview as invisiblei know its a very little mistake but unable to solve the error
Try View.GONE instead of View.INVISIBLE
Since you are doing this in onCreate you could do it in your XML:
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="200px"
android:visibility="gone"
/>
精彩评论