In my code I don't get any error
As I have problems with the init but no matter how many times I give it I can't find what the problem could be I am new to this it should also be emphasized, I have the libraries attached to the gradle and synchronized I have two other java classes where I have the listAdapter.
public class MainActivity extends AppCompatActivity {
List<ListElement> elements;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
}
public void init() {
elements = new ArrayList<>();
elements.add(new ListElement("#775447","Gustavo","Chiapas","Activo"));
elements.add(new ListElement("#772447","Eduardo","Guatemala","Nulo"));
elements.add(new ListElement("#725447","Jared","Guasave","Inac"));
elements.add(new ListElement("#785447","Juan","Zacatecas","Inactivo"));
elements.add(new ListElement("#720447","Ivan","Obregon","Cancelar"));
ListAdapter listAdapter = new ListAdapter(elements, this);
RecyclerView recyclerView = findViewById(R.id.listRecyclerView);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(listAdapter);
}
}
Voucher. It seems that the
id
enRecyclerView recyclerView = findViewById(R.id.listRecyclerView);
belongs to another view. Make sure theid
delRecyclerView
is the same in youractivity_main.xml
and in thefindViewById
.