Code example for ImageButton

Methods: setImageResource, setLayoutParams

0
 
    // create a new ImageView for each item referenced by the Adapter 
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageButton buttonView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
        	buttonView = new ImageButton(mContext);
        	buttonView.setLayoutParams(new GridView.LayoutParams(130, 200 ));
        } else { 
        	buttonView = (ImageButton) convertView;
        } 
 
        buttonView.setImageResource(mThumbIds[position]);
        return buttonView;
    } 
 
    // references to our images 
    private Integer[] mThumbIds = {
    		R.drawable.circulo, R.drawable.circulo, 
    		R.drawable.circulo, R.drawable.circulo 
    }; 
}