Long searched, but never found. I can not figure out how to do it. It is necessary from the list (ListView 3 items) when moving from each, open a new activation. At the moment, only the list opens and that's it. It turned out to open the activation, but on all three points the same one opens, but I forgot how I did it (do not scold me, starting only. Help with a piece of code that handles clicking on ListView items).

public class MainActivity extends ListActivity implements AdapterView.OnItemClickListener { final String[] radioNames = new String[]{"deep", "progressive", "dutch"}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ArrayAdapter<String> mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_expandable_list_item_1, radioNames ); setListAdapter(mAdapter); } @Override public void onListItemClick(ListView l, View itemClicked, int position, long id) { switch (getListView().getId()) { case R.id.listDeep: Intent intent = new Intent(this, DeepActivity.class); startActivity(intent); break; } } @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { } 

}

  • one
    You need to transfer through the list with the data + position in the list to get the necessary data, or transfer only the necessary data. Then, in the running activation, pull this data out of the intent - YuriySPb
  • @YuriSPb see part of my code. What am I doing wrong? - Dmitry Zenin
  • You do not have the code to attempt to transfer data with the Internet. It may also be necessary to assign a click listener to the list. Nobody uses this kind of activity at all - YuriySPb

0