I am trying to create an application that customizes shirts on android, now on my application i have created a gridview that shows the thumbnails of shirts for the user to select, i want the user to be able to click on any image and it displays as fullscreen in another activity, i havent been able to do it, i am stuck and i dont know where to continue or what to do.. please its my final year project, can someone help? below is my code:
The grid view code:
package com.efe.topprint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.Toast;
public class Gold extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gold);
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));
gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Toast.makeText(Gold.this, "" + position, Toast.LENGTH_SHORT).show();
}
});
}
}
The Imageadaptercode:
package com.efe.topprint;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
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 position;
}
// 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
public static Integer[] mThumbIds = {
R.drawable.gold, R.drawable.gold,
R.drawable.gold, R.drawable.gold,
R.drawable.gold, R.drawable.gold,
R.drawable.gold, R.drawable.gold,
R.drawable.gold, R.drawable.gold,
R.drawable.gold, R.drawable.gold,
R.drawable.gold, R.drawable.gold,
R.drawable.gold, R.drawable.gold,
};
}
everyhelp will be appreciated, i have 2 days to hand this in. its bin tough