Boa Tarde galera
Consegui resolver meu problema da seguinte maneira:
Passo 1: Crie o layout da ListView (cars_fragment.xml)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="@+id/cars_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Passo 2: Crie agora o layout do item da lista (item_cars_list.xml)
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="@android:color/transparent"
android:padding="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/car_image"
android:layout_width="48dp"
android:layout_height="48dp">
<TextView
android:id="@+id/car_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</android.support.constraint.ConstraintLayout>
Passo 3: Crie um adapter customizado
public class CarsAdapter extends ArrayAdapter<Car> {
private Context context;
private List<Car> cars = null;
public CarsAdapter(Context context, List<Car> cars) {
super(context, 0, cars);
this.cars = cars;
this.context = context;
}
@Override
public View getView(int position, View view, ViewGroup parent) {
Car car = cars.get(position);
if(view == null)
view = LayoutInflater.from(context).inflate(R.layout.item_cars_list, null);
ImageView carImage = (ImageView) view.findViewById(R.id.car_image);
carImage.setImageResource(car.getImagem());
TextView carName = (TextView) view.findViewById(R.id.car_name);
carName.setText(car.getNome());
return view;
}
}
Passo 4: Inflando a ListView no Fragment
@Nullable
@Override
public View onCreateView(
@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
// Observe que o primeiro argumento do inflate é o layout com a ListView que criamos no primeiro passo
View view = inflater.inflate(R.layout.cars_fragment, container, false);
// Aqui você instancia sua ListView
ListView carsList = (ListView) view.findViewById(R.id.cars_list);
List<Car> cars = null; // Obtenha sua lista de objetos aqui
CarsAdapter carsAdapter = new carsAdapter(getActivity(), cars);
carsList.setAdapter(carsAdapter);
return view;
}
Fonte: https://pt.stackoverflow.com/questions/336250/como-criar-um-listview-customizado-dentro-de-um-fragment/336277#336277
Testei aqui e tudo funcionou corretamente, fica a resposta caso alguém tenha algum problema parecido no futuro.
Obrigado.