开发者

Adapter.getItem(index) what return value?

开发者 https://www.devze.com 2023-03-28 20:51 出处:网络
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 i

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消