在Listview
删除最后一个选项中,当我应用选项菜单,删除任何列表项上的选项时,它只删除了最后一项我现在该怎么办?选择编辑选项时发生类似问题,它将选择或获取最后一项的信息,
final CharSequence[] gender = {"Edit","Delete"};
alert = new AlertDialog.Builder(StikiNotesActivity.this);
final AlertDialog.Builder alert_del = new AlertDialog.Builder(StikiNotesActivity.this);
alert_del.setTitle("Confirmation !");
alert.setTitle("Options");
alert.setItems(gender,new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
if(which==0)
{
Toast.makeText(getApplicationContext(), "EditOpetion"+alist.get(0).sid, Toast.LENGTH_SHORT).show();
final Intent i = new Intent(StikiNotesActivity.this,FirstClass.class);
//String txt=new String();
i.putExtra("id",""+alist.get(position).sid);
startActivity(i);
}
else if(which==1)
{
AlertDialog.Builder alertDialog=new AlertDialog.Builder(StikiNotesActivity.this);
alertDialog.setTitle("Selected Subject will be deleted");
alertDialog.setPositiveButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
alist.remove(position);
adap.notifyDataSetChanged();
dialog.cancel();
}
});
alertDialog.setNegativeButton("Cancel", null);
alertDialog.show();
}
}});
请帮我解决这个问题?