It is not possible to transfer a string from the activation to the fragment. I am new and in the answers on this topic confused. Someone writes need to do so, someone else. There is a fragment, it activates it, and from this it is necessary to “translate” the data into a fragment. Help me please

Fragment:

public class Home extends Fragment { public static Home newInstance() { Home fragment = new Home(); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.activity_home, container, false); } } 

Activity:

 public class SettingBD extends AppCompatActivity implements OnClickListener{ /* @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setting_bd); }*/ /*********************************************************************/ Button btnSave, btnLoad; EditText etText, etText2, etText3; SharedPreferences sPref, sPref2, sPref3; final String SAVED_TEXT_BD = "saved_textBD"; ---- ЭТО ЗНАЧЕНИЕ НЕОБХОДИМО ТРАНСЛИРОВАТЬ final String SAVED_TEXT2_BD = "saved_textBD2"; final String SAVED_TEXT3_BD = "saved_textBD3"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setting_bd); /*Сохранение значений полей*/ etText = (EditText) findViewById(R.id.editText1); etText2 = (EditText) findViewById(R.id.editText2); etText3 = (EditText) findViewById(R.id.editText3); btnSave = (Button) findViewById(R.id.saveBD); btnSave.setOnClickListener(this); btnLoad = (Button) findViewById(R.id.loadBD); btnLoad.setOnClickListener(this); loadText(); } } 
  • one
    To begin, add the code - danilshik
  • one
    In the above code I don’t see any attempt to transfer the value - danilshik
  • @ RinaBlack, in the activity code there is no explicit reference to the fragment. It also complicates the understanding of the lack of layouts in the question. Please add a question with missing materials. How to create a minimal, self-sufficient and reproducible example - Mikhail Rebrov

0