Reputation: 3913
I am having an issue with updation of GridView
items once its back from child activity. Once the griditem is clicked a child activity is opened which has two options as yes or no. I have to show an extra image in a gridview for that particular griditem
if user selects yes, if not it should be the same old gridview. I am getting if user selected yes or no in "onActivityResult
" present in GridView's activity. Now my issue is, I don't know how to show the extra image for that particular item in gridview. Any suggestions, please help me. Thanks a lot.
Upvotes: 0
Views: 844
Reputation: 131
Just Pass the Image from your child Activity like,
YesButton.setOnclickListener(new onClickListener()
{
public void onClick(View v)
{
Intent csIntent=new Intent();
csIntent.put("image","name");
setResult(RESULT_OK, csIntent);
finish();
}
});
and main Activity,
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
`enter code here`get that image and once again load and refresh the GridAdapter here.
}
Upvotes: 1
Reputation: 453
Set up your ImageView in your xml design file, and then when you get your onActivityResult try executing the code to set a source to your ImageView, it should work with this:
ImageView image = (ImageView) findViewById(R.id.test_image);
image.setImageResource(R.drawable.test2);
I hope this helped you.
Upvotes: 2
Reputation: 2386
Just set your image to an ImageView
and then add your ImageView
to the parent layout of your custom grid item layout with params
as your requirement.
Upvotes: 1