0
I wonder if it is possible to take a selected image and send it to another Activity. I’m using Fragments and wanted the layout to look like the image below.
Wanted that when the user selects the image, pick this and send to another Activity and present 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);
}
}
I think you made a mistake pasting the Adapter.
– viana