[Solved] Use two components from different layouts


What you want to do is have two separate activities, one to edit the text, and one to display it.

The first one you want to set the layout to layout_main, and set a callback for the button. Inside the callback you want:

final EditText text = (EditText)findViewById(R.id.broj1);
Intent intent = new Intent(MainAct.this, NumGen.class);
Bundle bundle = new Bundle();
bundle.putString("mString",text.getText().toString());
intent.putExtras(bundle);
startActivity(intent);

Then inside your second activity (NumGen?) you can get that string you saved by doing this:

Bundle data = getIntent().getExtras();
String mString="";
if(data.containsKey("mString")){ mString=data.getString("mString"); }

One of the main issues it looks like you might be having is the ids defined in your XML files aren’t the same as the ids in your code. After that, read up on how Activities work and pass information.

solved Use two components from different layouts