I'm new to this android apps development and currently, I'm creating an app that will get an image uri from the gallery to the listview on my activity. I have no problem with that. I just want to add a feature that when I clicked an image uri from my listview, a bitmap thumbnail of that image uri will appear. Here is my code:
ListView lv;
ArrayList<Uri> array_list = new ArrayList<Uri>();
ArrayAdapter<Uri> array_adapter;
final int RQS_LOADIMAGE = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
array_adapter = new ArrayAdapter<Uri>(MainActivity.this, android.R.layout.simple_list_item_1, array_list);
lv = (ListView)findViewById(R.id.list);
lv.setAdapter(array_adapter);
}
public void btn_ai(View view) {
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, RQS_LOADIMAGE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK){
switch(requestCode){
case RQS_LOADIMAGE:
Uri imageUri = data.getData();
array_list.add(imageUri);
array_adapter.notifyDataSetChanged();
break;
}
}
}
}