Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems sending data from one activity to another with application
    text
    copied!<p>As the title says I want to transfer data, in this case the information introduced by the user on an <code>EditText</code> and a <code>Spinner</code>, from one activity to another.</p> <p>I am following a tutorial from a book but it doesn't work (I think its not complete). Here the code of the program:</p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.main); this.location=(EditText)findViewById(R.id.location); this.cuisine=(Spinner)findViewById(R.id.cuisine); this.grabReviews=(Button)findViewById(R.id.get_reviews_button); ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.cuisine, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); this.cuisine.setAdapter(adapter); this.grabReviews.setOnClickListener(new OnClickListener() { public void onClick(View v) { handleGetReviews(); } } ); } private void handleGetReviews() { RestaurantsActivity application= (RestaurantsActivity) getApplication(); application.setReviewCriteriaCuisine(this.cuisine.getSelectedItem().toString()); application.setReviewCriteriaLocation(this.location.getText().toString()); Intent intent=new Intent(Constants.INTENT_ACTION_VIEW_LIST); startActivity(intent); } </code></pre> <p>This code above doesn't work. I dont understand four things:</p> <p>-<code>RestaurantsActivity</code> must be the actual activity right?</p> <p>-In all the examples I have seen over the internet there is an application extends class, in this example there isnt.</p> <p>-<code>setReviewCriteria</code> function is missing </p> <p>-Where does <code>Constants.INTENT_ACTION_VIEW_LIST</code> come from ?</p>
 

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