Adapter.getItem(index) what return value?
As i read Adapter.getItem(index)
can retreive a data from a ListView. For that reason, i have to use it to make some treatments. The problem is this function returns an object, and in my case i want it to return a String(as my datas are in String). Is there any solution tothis or any alternative ?
Thank you.
Code:
AlertDialog alert_reset;
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage("Supprimer cette donnee ?")
.setCancelable(false)
.开发者_Go百科setPositiveButton("Oui",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int id) {
adapter.getItem(arg2);// i want to retreive this
list.remove(arg2);
Simply change your Adapter.getItem() to return a String rather than object.
@Override
public String getItem(int pos) {
....
....
}
Alternatively, you could cast the Object to type String.
String myString = (String) adapter.getItem(arg2);
精彩评论