OK、私はオンラインでこれを理解しようとしていて、あちこちでコードのビットをつなぎ合わせていました。まだわかりません。私が望むのは、3 つのリスト項目を表示し、項目をクリックすると新しいアクティビティに移動することだけです。何を修正する必要がありますか?
編集:
私は愚かな間違いを犯しました。修正済み - みんなありがとう!
OK、私はオンラインでこれを理解しようとしていて、あちこちでコードのビットをつなぎ合わせていました。まだわかりません。私が望むのは、3 つのリスト項目を表示し、項目をクリックすると新しいアクティビティに移動することだけです。何を修正する必要がありますか?
編集:
私は愚かな間違いを犯しました。修正済み - みんなありがとう!
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.
サムとエルドゥデリノはどちらも有効なポイントを持っていますが、それでも面白いポイントとして:
アイテムが「Economy」「Basic」「Professional」などであるかどうかを確認していますが、文字列配列には1年の月しかありません...:P
また、インテントを設定するときは、を使用しないでください。これは、イベントに参加this
しているためです。つまり、はであり、ではありません。したがって、の代わりにを使用してください。onClick
this
onClickListener
Activity
atcList.this
this
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.
You never set the onItemClickListener to the listview:
myList.setOnItemClickListener(this);