Note that there are some explanatory texts on larger screens.

plurals
  1. POTransferring value between activities in Android not working
    primarykey
    data
    text
    <p>I am trying to produce a value with a temperature conversion which works and then have this value transferred into a blank text box in another activity but the code doesn't seem to be working. Here are the two parts - the one it is coming from and the one it needs to go to...</p> <pre><code>public class MainActivity extends Activity { private EditText text; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); text = (EditText)findViewById(R.id.MainActivityText); final EditText et = (EditText) findViewById(R.id.MainActivityText); Button b = (Button) findViewById(R.id.Button01); b.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent myIntent = new Intent(view.getContext(), SecondScreen.class); startActivityForResult(myIntent, 0); Intent intent=new Intent(MainActivity.this, SecondScreen.class); intent.putExtra("value", et.getText().toString()); startActivity(intent); } }); } @SuppressLint("NewApi") public class SecondScreen extends Activity { /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.secondscreen); TextView nameView=(TextView) findViewById(R.id.SecondScreenText); nameView.setText(getIntent().getExtras().getString("Value")); Button next = (Button) findViewById(R.id.Button02); next.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); } }); }} </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload