At that for some reason swears on onListItemClick. The main thing - I can not understand why. public void onCreate (Bundle savedInstanceState) {

super.onCreate(savedInstanceState); setContentView(R.layout.main); setTitle("New List"); listView = (ListView)findViewById(; adapter = new ItemAdapter(); adapter.addEnginesNames(names); adapter.addEnginesDescriptions(descriptions); adapter.addEnginesLogoUrl(logoUrl); listView.setAdapter(adapter); MyTask mt = new MyTask(); mt.execute(); listView.setOnScrollListener(new OnScrollListener() { @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { ... ... ... @Override public void onScrollStateChanged(AbsListView view, int scrollState) {} }); public void onListItemClick(ListView l; View v; int position; long id) { String item = (String) getListAdapter().getItem(position); Toast.makeText(this, "olololo" + item, Toast.LENGTH_LONG).show(); } } 

Underlines onListItemClick and writes: "also indicates the last bracket and writes:" Syntax error on token ")";; expected; "" Syntax error on token ")";; expected "

How to deal with it?

    2 answers 2

    onListItemClick This is not the place. this is a separate listener

     listView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int position, long id) { } } ); 
    • Underlined the first line and ..> Multiple markers at this line> - The method> setOnItemClickListener (AdapterView.OnItemClickListener) in the type> AdapterView <ListAdapter> - be resolved to a type - Stas0n
    • In the import, add the class OnItemClickListener - AndroidDev
    • and how to do so, to get to display what is highlighted? Something like> String item = (String) getListAdapter (). GetItem (position); > Toast.makeText (this, "ololo", Toast.LENGTH_LONG) .show (); - Stas0n 8:39
    • and also (ListView l; View v; int position; long id) .. there is generally instead of ";", it is better to put "," - Kerins_Sataier

    Hi, as AndroidDev said, onListItemClick is a separate listener. =) And to get a message with a selected item, use getAdapter (). GetItem (). Those. It should look like this:

     String[] values = new String[] { "String 1", "String 2", "String 3", "String 4", "String 5" }; ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, values); mListView = (ListView) findViewById(; mListView.setAdapter(mAdapter); mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { // Получение элемента, который был нажат Object obj = mListView.getAdapter().getItem(i); String item = obj.toString(); // Выводим сообщение с текстом выбранного элемента Toast.makeText(getApplicationContext(), "Вы выбрали: " + item, Toast.LENGTH_SHORT).show(); } }); 

    For the fact that after the "Copy-Paste" code will not work answer! ;) I wrote from memory, but the essence lies in this. I hope this example will help you.