リストビューがあり、ユーザーが項目を選択すると、データベース ( sqlite ) のデータと比較される新しいアクティビティが開き、データが取得されます。選択した項目の位置しか渡せないのですが、文字列自体は渡したいです。
最初のアクティビティのコード:
list.setAdapter(adapter);
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
Intent myIntent = new Intent(view.getContext(), ShowWhereToGo.class);
myIntent.putExtra("id", position);
startActivityForResult(myIntent, 0); // display SubView.class }
}
@SuppressWarnings("unused")
public void onItemClick1(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
}});
2 番目のアクティビティのコード:
Bundle extras = getIntent().getExtras();
if (extras != null) {
String temp = extras.getString("id");
Toast.makeText(getApplicationContext(),
"Position :"+temp , Toast.LENGTH_LONG)
.show();
}