1
I have a Fragment containing a Edittext in which the user will enter his name.
In another Fragment is the Textview that will receive the name typed in Fragment previous.
Fragment Edit (where the user will enter the name):
public class Editar extends Fragment implements View.OnClickListener{
private EditText editar; private Button okBotao;
View rootview;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootview = inflater.inflate(R.layout.fragment_editar, container, false);
editar = (EditText) rootview.findViewById(R.id.editar);
okBotao = (Button) getActivity().findViewById(R.id.ok);
okBotao.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
InicioActivity menu = new InicioActivity();
Bundle args = new Bundle();
args.putString("editar", String.valueOf(editar));
menu.setArguments(args);
}
});
return rootview;
}
}
Fragment Start (where the name will be displayed):
public class Inicio extends Fragment {
TextView text;
View rootview;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootview = inflater.inflate(R.layout.fragment_main, container, false);
TextView text = (TextView)getView().findViewById(R.id.campoNome);
String editar = getArguments().getString("editar");
text.setText(editar);
return rootview;
}
}
In my application Navigation Drawer.
Thank you for helping me. But my application is still not working. This error message displays: FATAL EXCEPTION: main java.lang.Runtimeexception: Unable to start Activity
– Rosilene
In the code you posted I don’t see any
mTransition
I suggest you ask another question with the corrected code and error log.– ramaral
The Bundle is null. I found it. The code I sent is the one I’m using, the only change I made was the one you said.
– Rosilene
So that’s the problem. Refer to the new question that when using getArguments() this is returning null.
– ramaral