I have two activities - a Home fragment activity, and a normal Options activity.
In my home fragment activity, I'm trying to update an EditText View using data retrieved from the Options activity.
Unfortunately, for some reason, the fragment activity cannot detect my view for updating. I'm not entirely sure why. Here is my function:
//update text box
public void updateUserData (String[] userArray){
Log.d("User Update:", "beginning...");
//get username
EditText et=(EditText)getActivity().findViewById(R.id.Input_Name);
if (et == null) {
Log.d("ERROR:", "View returning null");
}
if (userArray[0] != null) {
Log.d("Updating name:", userArray[0]);
et.setText(userArray[0]); }
}
The weird thing is... that formula for retrieving the EditText View works perfectly fine in other parts of my code. But here it always returns null. Any suggestions?
edit: here is where I call the function in OnCreateView:
if(getActivity().getIntent() != null && getActivity().getIntent().getExtras() != null) {
String[] prelimUserArray = getActivity().getIntent().getExtras().getStringArray("userArray");
updateUserData(prelimUserArray);
}