gpt4 book ai didi

android - 无法解析方法 'super(android.content.context,int,int,java.util.arraylist)'

转载 作者:行者123 更新时间:2023-11-29 19:46:03 25 4
gpt4 key购买 nike

这是我的自定义列表适配器

private class MyAdapter extends ArrayAdapter<ArrayList<BluetoothDevice>> {

ArrayList<BluetoothDevice> data;
Context context;

public MyAdapter(Context context, int resource, int textViewResourceId, ArrayList<BluetoothDevice> objects) {
super(context, resource, textViewResourceId,objects);
this.context=context;
this.data=objects;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

View v=getLayoutInflater().inflate(R.layout.row,parent,false);

TextView textView=(TextView)findViewById(R.id.row_textview);

BluetoothDevice device=data.get(position);

textView.setText(device.getName()+"");



return v;
}
}

我正在传递一个蓝牙设备的数组列表,构造函数导致了问题

Canot resolve method 'super(android.content.context,int,int,java.util.arraylist<android.Bluetooth.Bluetoothdevices>)'

我在这里设置适配器

listView.setAdapter(new MyAdapter(getApplicationContext(),R.layout.row,R.id.row_textview,bluetoothDeviceArrayList));

请帮忙!

最佳答案

尝试改变这个

  private class MyAdapter extends ArrayAdapter<ArrayList<BluetoothDevice>> {

对此

  private class MyAdapter extends ArrayAdapter<BluetoothDevice> {

删除 ArrayList 部分。这只需要一个元素将处理的数据类型。

关于android - 无法解析方法 'super(android.content.context,int,int,java.util.arraylist<android.Bluetooth.Bluetoothdevices>)',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37670610/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com