Note that there are some explanatory texts on larger screens.

plurals
  1. POLaunch one activity from another with an item value
    primarykey
    data
    text
    <p>I have a ListActivity:</p> <pre><code>public class MedTime extends ListActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.no_elements_l); String[] receipts = getResources().getStringArray(R.array.receipts_array); setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.list_item, receipts)); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { // When clicked, show a toast with the TextView text Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show(); } </code></pre> <p>I'd like: when user clicks on list item, new activity named "view" launches. In addition, i need to say to this "view" activity which element from list called it. For example, if I click to 3rd element of list, activity "view" must be started and show me text = 3rd element of string array. The code fragment of "view" is here (value of i in last line must be sent by main activity to this, in my example i=3):</p> <pre><code>String[] receipts = getResources().getStringArray(R.array.receipts_array); TextView tv = new TextView(this); tv.setText(receipts[i]); </code></pre> <p>Please, tell me how to 1) launch "view" activity when user click a list item; 2) how to launch in this case "view" with the parameter that describes number of item selected?</p>
    singulars
    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