Switch:case for redirecting to other activity from the gridview menu

Go To StackoverFlow.com

1

It just wont open the next activity for any switch case from the menu. From menu click or touch on any item(position) should open the related activity. An example code or correction wud be help. Thanks!

  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,

};

}

2012-04-03 23:28
by mmehdisalehi
What is the error you are receiving? Can we see some output from Logcat - Jared Burrows 2012-04-04 02:57


0

Can you try:

Intent intent = new Intent(Main.this, CAMERA.class);
startActivity(intent);
2012-04-04 00:56
by Mark Pazon
It worked.. Thanks! Mussharapp - mmehdisalehi 2012-04-04 17:36
Welcome sir. = - Mark Pazon 2012-04-05 02:55