@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
addBtn = (Button)findViewById(R.id.addBtn);
itemInput = (EditText)findViewById(R.id.itemInput);
addBtn.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
addItem(itemInput.getText().toString());
itemInput.setText("");
}
});
handler = new MyDbHandler(this,null,null,1);
mylist = (ListView) findViewById(R.id.listView);
mylist.setOnItemClickListener(
new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
Log.d("Clicked item id", " "+position);
}
});
getList();
}
Above is my main Activity, after looking around i found a solution that said the position parameter represents my items id in the database but that didn't work for me. I would like to get the database id of the item that is clicked on my list.
Aucun commentaire:
Enregistrer un commentaire