I'm a bit lost already, I want when I click on an item in the list it opens another activity, but I only get toast ... I'm a beginner so if you can help me thank you.
public class estatisticas extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_estatisticas);
int position = getIntent().getIntExtra("a", 1);
final ListView lista = findViewById(R.id.Listview);
final ArrayList<String> estatisticas = preencherdados();
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, estatisticas);
lista.setAdapter(arrayAdapter);
lista.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
estatisticas artilheiros = (estatisticas) lista.getItemAtPosition(1);
Intent it = new Intent(estatisticas.this, artilheiros.class);
startActivity(it);
it.putExtra("a", position = 1);
}
});
}
private ArrayList<String> preencherdados() {
ArrayList<String> dados = new ArrayList<String>();
dados.add("TOP 15 ARTILHEIROS");
dados.add("Campeões");
return dados;
}
}