I have created this in an activity:
protected void onClickSunSea(View v) {
persons = (EditText) findViewById(R.id.txtPerson);
days = (EditText) findViewById(R.id.txtDays);
String p = persons.getText().toString();
String d = days.getText().toString();
String [] array = getResources().getStringArray(R.array.sunsea);
Intent myintent = new Intent(MainActivity.this, MainActivity.class);
myintent.putExtra("PERSONS", p);
myintent.putExtra("DAYS", d);
myintent.putExtra("PLACES",array);
startActivity(myintent);
}
To send to this activity:
String person = getIntent().getStringExtra("PERSONS");
String day = getIntent().getStringExtra("DAYS");
TextView txtPerson = (TextView) findViewById(R.id.txtViewPersons);
txtPerson.setText("Persons travelling: " + person);
TextView txtDay = (TextView) findViewById(R.id.txtViewDays);
txtDay.setText("Days of traveling: " + day);
String[] arrayCityBreak = getIntent().getStringArrayExtra("PLACES");
ArrayAdapter<String> adapterCityBreak = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, arrayCityBreak);
ListView myview = (ListView) findViewById(R.id.lstView);
myview.setAdapter(adapterCityBreak);
I have made these arrays in strings.xml:
<resources>
<string name="app_name">Assignment</string>
<array name="citybreak">
<item>Barcelona, Spain</item>
<item>Berlin, Germany</item>
<item>Copenhagen, Denmark</item>
<item>Gothenburg, Sweden</item>
<item>Milan, Italy</item>
</array>
<array name="sunsea">
<item>Alicante, Spain</item>
<item>Antalya, Turkey</item>
<item>Athens, Greece</item>
<item>Florida, USA</item>
<item>Gran Canaria, Spain</item>
</array>
<array name="skisnow">
<item>Kiruna, Sweden</item>
<item>Trondheim, Norway</item>
<item>Salzburg, Austria</item>
<item>Kittila, Finland</item>
<item>Ivalo, Finland</item>
</array>
I want to insert a subitem with a price inside it, for example: Barcelona, Spain 200 And then get that "200" value in a variable and change it, and then put it back in the array to write it out with the new value + some text before it. Like this: Barcelona, Spain the cost for 2 persons is 400 Can anyone help me with that? Hope you understand my question.