Answer the question
In order to leave comments, you need to log in
How to access image view in fragment?
I'm new, don't judge too harshly. I'm trying to do it this way:
public void accInfoFunc(){
acc_frag = new infoAccount();
fTrans = getFragmentManager().beginTransaction();
fTrans.replace(R.id.fragmentCont, acc_frag);
fTrans.commit();
ImageView avaInInfo = (ImageView) findViewById(R.id.myAvaInInfo);
avaInInfo.setImageResource(R.drawable.ic_menu_camera);
//Picasso.with(this).load(avaUrl).into(avaInInfo);
}
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageResource(int)' on a null object reference
Answer the question
In order to leave comments, you need to log in
Everything is wrong in your code, starting with the naming.
No one outside the fragment should know what views it has inside (encapsulation). Pass all the data to the fragment through setArguments, get it inside using getArguments, set the picture in the onCreateView or onViewCreated method.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question