我似乎收到此错误,我是 Android Studio 的新手,我正在尝试将名称从数组获取到 a 中,ListView然后当用户点击任何列表时 aToast被激活。但我似乎被以下错误困扰:
error: no suitable method found for makeText(MainActivity,Object,int)
method Toast.makeText(Context,CharSequence,int) is not applicable
(argument mismatch; Object cannot be converted to CharSequence)
method Toast.makeText(Context,int,int) is not applicable
(argument mismatch; Object cannot be converted to int)
这是我的代码:
final ArrayList names = new ArrayList();
names.add("Samuel");
names.add("Manuel");
names.add("King");
listv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(MainActivity.this, names.get(position), Toast.LENGTH_LONG).show();
}
});
有什么问题以及如何解决这个问题?
阿波罗的战车
莫回无
尚方宝剑之说
相关分类