无法解析构造函数'ArrayAdapter(AddChildActivity, int, void)'



无法解析构造函数'ArrayAdapter(com.alburraq.mapschoolbus.activities.AddChildActivity, int, void('

我想在自动完成文本视图中显示数组列表

for (int i = 0; i < Constants.followArrayList.size(); i++) {
loadVehicles(Constants.followArrayList.get(i).getOwnerID());
ArrayAdapter<String> adapter = new ArrayAdapter<String>
(this, android.R.layout.simple_list_item_1, loadVehicles(Constants.followArrayList.get(i).getOwnerID()) );
mAutocompleteTextViewBus.setThreshold(1); //will start working from first character
mAutocompleteTextViewBus.setAdapter(adapter);
}
private void loadVehicles(final String ownerID) {
FirebaseDatabase.getInstance().getReference("vehicles").orderByChild("ownerId").equalTo(ownerID).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
Vehicle vehicle = new Vehicle();
vehicle.setId("" + postSnapshot.getKey());
vehicle.setDriverName("" + postSnapshot.child("driverName").getValue());
vehicle.setDriverPhone("" + postSnapshot.child("driverPhone").getValue());
vehicle.setDriverPin("" + postSnapshot.child("driverPin").getValue());
vehicle.setImage("" + postSnapshot.child("image").getValue());
vehicle.setIsActive(Integer.parseInt("" + postSnapshot.child("isActive").getValue()));
vehicle.setLatitude("" + postSnapshot.child("latitude").getValue());
vehicle.setLongitude("" + postSnapshot.child("longitude").getValue());
vehicle.setNumber("" + postSnapshot.child("number").getValue());
vehicle.setOwnerId("" + postSnapshot.child("ownerId").getValue());
// if (vehicle.getIsActive() == 1) {
vehicles.add(vehicle);
//}
}
Constants.dismissSpinner();
}
@Override
public void onCancelled(DatabaseError error) {
Constants.dismissSpinner();
loadVehicles(ownerID);
}
});
Constants.dismissSpinner();
}

无法解析构造函数 'ArrayAdapter(com.alburraq.mapschoolbus.activities.AddChildActivity, int, void('

您的问题在于以下行:

ArrayAdapter<String> adapter = new ArrayAdapter<String>
(this, android.R.layout.simple_list_item_1, loadVehicles(Constants.followArrayList.get(i).getOwnerID()) );

ArrayAdapter拥有的唯一泛型构造函数是(来自文档(:

ArrayAdapter(Context context, int resource( 构造函数

ArrayAdapter(Context context, int resource, int textViewResourceId( 构造 函数

ArrayAdapter(Context context, int resource, T[] objects( 构造函数。

ArrayAdapter(Context context, int resource, int textViewResourceId, T[] 对象( 构造函数。

ArrayAdapter(上下文上下文、int 资源、列表对象( 构造 函数

ArrayAdapter(Context context, int resource, int textViewResourceId, 列出对象(构造函数

如果要从loadVehicles方法传入响应,则需要返回一个值。目前您有:private **void** loadVehicles(final String ownerID).

ArrayAdapter中,构造函数ArrayAdapter(context, int, void)不存在。

您正在使用:

ArrayAdapter<String> adapter = new ArrayAdapter<String>
(this, android.R.layout.simple_list_item_1, loadVehicles(Constants.followArrayList.get(i).getOwnerID()) );

loadVehicles(final String ownerID)返回void.

使用以下构造函数之一:

ArrayAdapter(Context context, int resource)
ArrayAdapter(Context context, int resource, int textViewResourceId)
ArrayAdapter(Context context, int resource, T[] objects)
ArrayAdapter(Context context, int resource, int textViewResourceId, T[] objects)
ArrayAdapter(Context context, int resource, List<T> objects)
ArrayAdapter(Context context, int resource, int textViewResourceId, List<T> objects)

最新更新