ListViewの選択項目に書き込みたいです。
public class MainActivity extends ListActivity {
private BenzinCursorAdapter Adapter;
private BenzinDbLoader dbLoader;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
dbLoader = new BenzinDbLoader(getApplicationContext());
dbLoader.open();
Cursor c = dbLoader.fetchAll();
Adapter = new BenzinCursorAdapter(getApplicationContext(), c);
setListAdapter(Adapter);
getListView().setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent,
View v, int position, long id){
//Benzin selectedbenzin = (Benzin) parent.getSelectedItem();
Benzin selectedbenzin = (Benzin) getListAdapter().getItem(position);
Toast.makeText(MainActivity.this, selectedbenzin.getDate(), Toast.LENGTH_LONG).show();
}
});
registerForContextMenu(getListView());
}
Benzin 要素の ListView アイテム
public class Benzin {
private String Date;
private String Kmo;
private String Mkm;
private String Hl;
private String Mft;
private String Af;
private String Osszk;
public Benzin(String aDate, String aKmo, String aMkm, String aHl,
String aMft, String aAf, String aOsszk) {
Date = aDate;
Kmo = aKmo;
Mkm = aMkm;
Hl = aHl;
Mft = aMft;
Af = aAf;
Osszk = aOsszk;
}
public String getDate() {
return Date;
}
public String getKmo() {
return Kmo;
}
public String getMkm() {
return Mkm;
}
public String getHl() {
return Hl;
}
public String getMft() {
return Mft;
}
public String getAf() {
return Af;
}
public String getOsszk() {
return Osszk;
}
}
ListViewで選択したアイテムを書きたいのですが、これが起こります
なぜこれが起こったのですか?
ありがとうございます