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,
};
}
Can you try:
Intent intent = new Intent(Main.this, CAMERA.class);
startActivity(intent);