I have a problem when trying to access my dialogs fragments view. Here is what I do:
For each button in my main activity I create a new dialogFragment when the button is clicked:
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
DialogFragment newFragment = ResAmountDialog.newInstance(R.string.res_dialog_title);
newFragment.show(getFragmentManager(), "dialog");
ImageView resIcon = (ImageView) newFragment.getView().findViewById(R.id.resourceIcon1);
resIcon.setImageResource(currentResourceImage);
}
});
The dialog fragment consists of an EditText and ImageView. I'm trying to access the imageView in the above code by getting the fragment, then its view and then finding it by ID, but it returns null.
I tried to find a solution on the internet but all the similar problems had their views accessed within the fragment, i try to access it from outside.