I am working on an app, that consists of 3 fragments. There are three numberDecimal|numberSigned EditTexts and a button on the first fragment and I need to get values from them on the third fragment (as float variables to build a graph) when the user clicks the button, how can I do this?
edit: I need to send float variables from one fragment to another when the user clicks the button
another edit: code with error
CodePudding user response:
What you posted here is just your adapter class but If I understood your question you want to pass data.
When you click the button goes to 3rd fragment with certain data
OnClick
ThirdFragment thirdFragment = new ThirdFragment ();
Bundle graph = new Bundle();
graph.putExtra("x", editTextX.getText().toString() "f");
graph.putExtra("y", editTextY.getText().toString() "f"));
graph.putExtra("z", editTextZ.getText().toString() "f");
thirdFragment.setArguments(graph);
//Inflate the fragment
getFragmentManager().beginTransaction().add(R.id.container, thirdFragment).commit();
When receiving at 3rd fragment
float x = getArguments().getFloat("x");
float y = getArguments().getFloat("y");
float z = getArguments().getFloat("z");
CodePudding user response:
Static variables solved my problem