I wonder if it's possible to grab a selected image and send it to another activity. I'm using fragments and wanted the layout to look like the image below.
I would like that when the user selects the image, pick this one and send it to another activity and present it on the screen. Class Fragment:
public class Fragment1 extends Fragment {
GridView gridView;
int [] listaImagens = new int[]{R.drawable.eu, R.drawable.perguntas, R.drawable.respostas};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup conteiner, Bundle saveInstanceState) {
View view = inflater.inflate(R.layout.layout_frag_1, conteiner, false);
gridView = (GridView) view.findViewById(R.id.imageFrag1);
gridView.setAdapter(new Adaptador(view.getContext(), listaImagens));
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Toast.makeText(parent.getContext(), "Imagem " +listaImagens[position], Toast.LENGTH_SHORT).show();
}
});
return (view);
}
}
Class Adapter:
public class Fragment1 extends Fragment {
GridView gridView;
int [] listaImagens = new int[]{R.drawable.eu, R.drawable.perguntas, R.drawable.respostas};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup conteiner, Bundle saveInstanceState) {
View view = inflater.inflate(R.layout.layout_frag_1, conteiner, false);
gridView = (GridView) view.findViewById(R.id.imageFrag1);
gridView.setAdapter(new Adaptador(view.getContext(), listaImagens));
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Toast.makeText(parent.getContext(), "Imagem " +listaImagens[position], Toast.LENGTH_SHORT).show();
}
});
return (view);
}
}