I created a custom listview, it's all right, I've tried it here but it's not right, I wanted to implement the click on an item, but since it's custom listview maybe it's something different,
public class artilheiros extends AppCompatActivity {
int [] Imagens = {R.drawable.arg, R.drawable.bolivia, R.drawable.brasil, R.drawable.chile,
R.drawable.colombia, R.drawable.chile, R.drawable.paraguai, R.drawable.uruguai,
R.drawable.arg, R.drawable.bolivia, R.drawable.brasil, R.drawable.chile,
R.drawable.colombia, R.drawable.chile, R.drawable.paraguai};
String [] Nomes = {"ART 1", "ART 2", "ART 3", "ART 4", "ART 5", "ART 6", "ART 7", "ART 8",
"ART 9", "ART 10", "ART 11", "ART 12", "ART 13", "ART 14", "ART 15"};
String [] Times = {"TIME 1", "TIME 2", "TIME 3", "TIME 4", "TIME 5", "TIME 6", "TIME 7",
"TIME 8", "TIME 9", "TIME 10", "TIME 11", "TIME 12", "TIME 13", "TIME 14", "TIME 15"};
String [] Gols = {"999 gols", "999 gols", "999 gols", "999 gols", "999 gols", "999 gols", "999 gols",
"999 gols", "999 gols", "999 gols", "999 gols", "999 gols", "999 gols", "999 gols", "999 gols"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_artilheiros);
ListView listview = findViewById(R.id.listviewart);
CustomAdapter customAdapter = new CustomAdapter();
listview.setAdapter(customAdapter);
}
class CustomAdapter extends BaseAdapter{
@Override
public int getCount() {
return Imagens.length;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = getLayoutInflater().inflate(R.layout.customlistview, null);
ImageView imageView = (ImageView) convertView.findViewById(R.id.imageView);
TextView textViewnome = (TextView) convertView.findViewById(R.id.textViewnome);
TextView textViewtime = (TextView) convertView.findViewById(R.id.textViewtime);
TextView textViewgols = (TextView) convertView.findViewById(R.id.textViewgols);
imageView.setImageResource(Imagens[position]);
textViewnome.setText(Nomes[position]);
textViewtime.setText(Times[position]);
textViewgols.setText(Gols[position]);
return convertView;
}
}
}
I used this method, but all the items in the list open the same activity ...
int position = getIntent().getIntExtra("a", 0);
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
artilheiros a1 = (artilheiros) listview.getItemAtPosition(0);
Intent it = new Intent(artilheiros.this, campeoes.class);
it.putExtra("a1", position);
startActivity(it);
}
});