How to Put a Linear Layout

f a ListView. Not it has a few options for defining the width of a column and number of columns:

<?xml version="1.0" encoding="utf-8"?>  
<GridView xmlns:android="http://schemas.android.com/apk/res/android
    android:id="@+id/image_list" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:columnWidth="@dimen/button_width" 
    android:numColumns="auto_fit" >  
 
</GridView> 
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/image_list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnWidth="@dimen/button_width"
    android:numColumns="auto_fit" >

</GridView>

And the activity has to change to use the GridView instead of ListView:

public class MyActivity extends FragmentActivity  
{  
     
    @Override 
    protected void onCreate(Bundle savedInstanceState)  
    {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.image_list);  
          
        GridView imageList = (GridView) findViewById(R.id.image_list);  
        final ImageStuffAdapter imageAdapter = new ImageStuffAdapter(this);  
        imageList.setAdapter(imageAdapter);  
        imageList.setBackgroundResource(R.drawable.bkg);  
    }  

Back  [1] [2] [3] 

Copyright © 2007-2012 www.chuibin.com Chuibin Copyright