I wonder if there is a way to work with images on android. I have a List View, in this list I have several categories. When the user selects this category, I would like to load all images related to this category. But I do not know how to do this, I'm using fragments. I have an xml file with the list view and another one with the fragment where the images would appear.
This is the main class:
public class MainActivity extends FragmentActivity {
FragmentManager fm = getSupportFragmentManager();
ListView listItemView;
String[] listaCategorias = new String[]{"INÍCIO", "RESPOSTAS","PERGUNTAS","ALFABETO","ALMOÇO","BEBIDAS", "COMO ESTOU ME SENTINDO",
"EU QUERO","FAMILIA", "FRUTAS", "HIGIENE FEMININA", "HIGIENE MASCULINA","INFORMÁTICA", "LEGUMES", "MANICURE",
"MAQUIAGEM","MUSICAS", "NUMERAIS","ONDE ESTÁ?", "SENTIMENTOS", "TAMANHOS", "VERDURAS"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Fragment1 fragment1 = (Fragment1) fm.findFragmentById(R.id.fragment1);
listItemView = (ListView) findViewById(R.id.listView1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, listaCategorias);
listItemView.setAdapter(adapter);
listItemView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(MainActivity.this, listaCategorias[position], Toast.LENGTH_SHORT).show();
switch (position){
case 1:
}
}
});
}
And this is the class fragment, in which the images would appear:
public class Fragment1 extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup conteiner, Bundle saveInstanceState) {
View view = inflater.inflate(R.layout.layout_frag_1, conteiner, false);
/*ImageView imageView = null;
imageView.findViewById( R.id.imageView ) ;
Glide . with ( this )
. load ( "http://goo.gl/gEgYUd" )
. into ( imageView ) ;*/
return (view);
}