Hello I've got some code that pulls pulls in data from a database via a PHP service layer using JSON etc and displays it as a listview. It works and I'm very happy with it - but I wanted to add an onClickListener to it.
I know how to do it for buttons but its proving more difficult for the list view. I basically want it to take the ID taken from the JSON and put it into an intent to another activity. This is my class... public class OnlineScores extends Activity { /** ListView that holds item references */ ListView li; /** *Array adapter that will hold an ArrayList of invoked items *and display these in the ListView */ EventAdapter arrayAdapter; String eventURL; /** Houses the invoked items */ ArrayList<Event> a = new ArrayList<Event>(); @Override /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.lmain); Intent intent = this.getIntent(); Bundle b = intent.getExtras(); eventURL = b.getString("URL"); //Initialise ListView li=(ListView)findViewById(R.id.lstText); arrayAdapter = new EventAdapter(OnlineScores.this,R.layout.list,a); // Set above adapter for the ArrayList li.setAdapter(arrayAdapter); // Create an object of the GetData class GetData g = new GetData(); String response = g.getIt("","",eventURL); try { // Put JSON response into an object Type collectionType = new TypeToken<ArrayList<Event>>() {}.getType(); List <Event> lst= new Gson().fromJson(response, collectionType); for(Event l : lst) { a.add(l); } // Inform the ArrayAdapter of the change from ArrayList to List arrayAdapter.notifyDataSetChanged(); } catch(Exception e) { } } } I'm trying to implement this... lstText.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int position, long id) { // Do stuff here } }); but I'm being told to remove the @Override statement AND to inherit abstract methods. Any ideas? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en