1

メニューからスイッチケースの次のアクティビティを開くことはありません。メニューから任意の項目 (位置) をクリックまたはタッチすると、関連するアクティビティが開きます。コードの例または修正が役立ちます。ありがとう!

  Menu.java
public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.options);
    GridView gridview = (GridView) findViewById(R.id.gridview);
    gridview.setAdapter(new ImageAdapter(this));

    gridview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, 
 longid) {
            switch (position) {
            case 0:
                 Intent intent = new Intent("mjour.fyp.CAMERA");
                    startActivity(intent);
                   break;


        }
            return;
            }

ImageAdapter.java

 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 null;
}

public long getItemId(int position) {
    return 0;
}

// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView;
    if (convertView == null) {  // if it's not recycled, initialize some attributes
        imageView = new ImageView(mContext);
        imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setPadding(8, 8, 8, 8);
    } else {
        imageView = (ImageView) convertView;
    }

    imageView.setImageResource(mThumbIds[position]);
    return imageView;
}

// references to our images
private Integer[] mThumbIds = {
        R.drawable.camera, R.drawable.camera,
        R.drawable.camera, R.drawable.camera,
        R.drawable.camera, R.drawable.camera,
        R.drawable.camera, R.drawable.camera,

};

}

4

1 に答える 1

0

試すことができますか:

Intent intent = new Intent(Main.this, CAMERA.class);
startActivity(intent);
于 2012-04-04T00:56:13.323 に答える