コード2


public abstract void onItemClick (AdapterView<?> parent, View view, int position, long id)
Since: API Level 1

Callback method to be invoked when an item in this AdapterView has been clicked.

Implementers can call getItemAtPosition(position) if they need to access the data associated with the selected item.

Parameters :
parent 	   The AdapterView where the click happened.

view 	   The view within the AdapterView that was clicked (this   
           will be a view provided by the adapter)

position   The position of the view in the adapter.

id 	     The row id of the item that was clicked.
public TabMenu(Context context,OnItemClickListener titleClick,OnItemClickListener bodyClick,  
             MenuTitleAdapter titleAdapter,int colorBgTabMenu,int aniTabMenu){  
         super(context);  
           
         mLayout = new LinearLayout(context);  
         mLayout.setOrientation(LinearLayout.VERTICAL);  
         //       
         gvTitle = new GridView(context);  
         gvTitle.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));  
         gvTitle.setNumColumns(titleAdapter.getCount());  
         gvTitle.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);  
         gvTitle.setVerticalSpacing(1);  //    
         gvTitle.setHorizontalSpacing(1);  //    
         gvTitle.setGravity(Gravity.CENTER);  
         gvTitle.setOnItemClickListener(titleClick);  
         gvTitle.setAdapter(titleAdapter);  
         gvTitle.setSelector(new ColorDrawable(Color.TRANSPARENT));//           
         this.titleAdapter=titleAdapter;  
         //      
         gvBody = new GridView(context);  
         gvBody.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));  
         gvBody.setSelector(new ColorDrawable(Color.TRANSPARENT));//           
         gvBody.setNumColumns(4);  
         gvBody.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);  
         gvBody.setVerticalSpacing(10);  
         gvBody.setHorizontalSpacing(10);  
         gvBody.setPadding(10, 10, 10, 10);  
         gvBody.setGravity(Gravity.CENTER);  
         gvBody.setOnItemClickListener(bodyClick);  
         mLayout.addView(gvTitle);  
         mLayout.addView(gvBody);  
           
         //       
         this.setContentView(mLayout);  
         this.setWidth(LayoutParams.FILL_PARENT);  
         this.setHeight(LayoutParams.WRAP_CONTENT);  
         this.setBackgroundDrawable(new ColorDrawable(colorBgTabMenu));//   TabMenu      
         this.setAnimationStyle(aniTabMenu);  
         this.setFocusable(true);// menu               menu              
     }
private LinearLayout makeMenyBody(int position)  
         {  
             LinearLayout result=new LinearLayout(this.mContext);  
             result.setOrientation(LinearLayout.VERTICAL);  
             result.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);     
             result.setPadding(10, 10, 10, 10);  
               
             TextView text = new TextView(this.mContext);  
             text.setText(texts[position]);  
             text.setTextSize(fontSize);  
             text.setTextColor(fontColor);  
             text.setGravity(Gravity.CENTER);  
             text.setPadding(5, 5, 5, 5);  
             ImageView img=new ImageView(this.mContext);  
             img.setBackgroundResource(resID[position]);  
             result.addView(img,new LinearLayout.LayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)));  
             result.addView(text);  
             return result;  
         }
//      ,       Gallery Adapter
public class ImageAdapter extends BaseAdapter {
        private Context mContext;
        public ImageAdapter(Context c) {
            mContext = c;
        }
        public int getCount() {
            return mThumbIds.length;
        }
        public Object getItem(int position) {
            return position;
        }
        public long getItemId(int position) {
            return position;
        }
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i = new ImageView(mContext);
            i.setImageResource(mThumbIds[position]);
            i.setAdjustViewBounds(true);
            i.setLayoutParams(new Gallery.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            i.setBackgroundResource(R.drawable.picture_frame);
            return i;
        }
    }
private Integer[] mThumbIds = {
            R.drawable.sample_thumb_0, R.drawable.sample_thumb_1,
            R.drawable.sample_thumb_2, R.drawable.sample_thumb_3,
            R.drawable.sample_thumb_4, R.drawable.sample_thumb_5,
            R.drawable.sample_thumb_6, R.drawable.sample_thumb_7};
//makeView ImageSwitcher       ,     //mSwitcher.setFactory(this)  ,     makeView
public View makeView() {
        ImageView i = new ImageView(this);
        i.setBackgroundColor(0xFF000000);
        i.setScaleType(ImageView.ScaleType.FIT_CENTER);
        i.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT));
        return i;
    }
<TextView android:id="@+id/label" style="?android:attr/textAppearanceMediumInverse" //    ?
        android:layout_width="match_parent" android:layout_height="wrap_content"
        android:layout_weight="0"
        android:padding="4dip"
        android:singleLine="true"
        android:color="?android:attr/textColorPrimaryInverse" //    
        android:background="#888" />

// Tell the media scanner about the new file so that it is
// immediately available to the user.        
            MediaScannerConnection.scanFile(this,
                    new String[] { file.toString() }, null,
                    new MediaScannerConnection.OnScanCompletedListener() {
                public void onScanCompleted(String path, Uri uri) {
                    Log.i("ExternalStorage", "Scanned " + path + ":");
                    Log.i("ExternalStorage", "-> uri=" + uri);
                }
            });