0

OK I've been online trying to figure this out, and piecing together bits of code here and there. I still don't understand. All I want is to display three list items and on item click it would go to a new activity. What do I need to fix?

Edit:

I made a stupid mistake. Fixed now - thanks everyone!

2
  • 2
    if you are getting error then post logcat stacktrace May 9, 2012 at 18:53
  • 1
    I'm confused by your list. it contains the months of the year but you are looking for the terms "Basic", "Professional", etc....
    – Woodsy
    May 9, 2012 at 18:57

4 Answers 4

1

I'm going to guess that you should replace this:

String item = (String) getListAdapter().getItem(position);

with this:

String item = view.getText().toString();

getListAdapter() is a function for a ListActivity but not a regular Activity.

0

Are you sure that you have your new activity classes in the android manifest? You need to add each activity you are going to launch to the manifest.

Check your manifest.xml and declare the activities and you should be good to go. Also change the way you get the info from the listener to so that you getString from the item instead of using the position. That way you can control exactly what is passed to your intent by specifying the textview on the item.

0

Sam and El Duderino both have valid points, but just as an amusing point nonetheless:

You're checking to see if the items are "Economy" "Basic" "Professional", etc., but your String array has only the months of the year ... :P

Also, when setting the Intents, you should not be using this, because you are in the onClick event, which means this is an onClickListener and not an Activity. So use atcList.this instead of just this.

0

You never set the onItemClickListener to the listview:

myList.setOnItemClickListener(this);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.