I can not get this list displayed. I'm using a Custon ArrayAdapter, but it's not rolling. Thanks. Debugging, it says "Frame not availeble". Could someone give me a light?
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayList<EventK> eventK = new ArrayList<>();
/*cria arraylist de eventos
*(nome do evento, data, hora, distancia, preço 1|2, pessoas confirmadas
*/
eventK.add(new EventK("Cosmic Boys - Curitiba PR", "2017-02-14" , "10h00", "0|0",
"1,5km", R.drawable.event_1, 1));
eventK.add(new EventK("Cosmic Boys - Curitiba PR", "2017-02-14" , "10h00", "0|0",
"1,5km", R.drawable.event_1, 2));
eventK.add(new EventK("Cosmic Boys - Curitiba PR", "2017-02-14" , "10h00", "0|0",
"1,5km", R.drawable.event_1, 3));
eventK.add(new EventK("Cosmic Boys - Curitiba PR", "2017-02-14" , "10h00", "0|0",
"1,5km", R.drawable.event_1, 4));
eventK.add(new EventK("Cosmic Boys - Curitiba PR", "2017-02-14" , "10h00", "0|0",
"1,5km", R.drawable.event_1, 5));
eventK.add(new EventK("Cosmic Boys - Curitiba PR", "2017-02-14" , "10h00", "0|0",
"1,5km", R.drawable.event_1, 6));
eventK.add(new EventK("Cosmic Boys - Curitiba PR", "2017-02-14" , "10h00", "0|0",
"1,5km", R.drawable.event_1, 7));
EventAdapter eventAdapter = new EventAdapter(this, eventK);
ListView listView = (ListView)findViewById(R.id.list_events);
listView.setAdapter(eventAdapter);
}
}
Here's the Adapter:
public class EventAdapter extends ArrayAdapter<EventK> {
public EventAdapter(Context context, ArrayList<EventK> eventK) {
super(context, 0, eventK);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View listItemView = convertView;
if (listItemView == null) {
listItemView = LayoutInflater.from(getContext()).inflate(R.layout.event_item, parent, false);
}
EventK currentEvent = getItem(position);
TextView nameTextView = (TextView) listItemView.findViewById(R.id.event_name);
if (currentEvent != null) {
nameTextView.setText(currentEvent.getEventName());
//TextView hourTextView = (TextView) listItemView.findViewById(R.id.event_hour);
//hourTextView.setText(currentEvent.getEventHour());
TextView distanceTextView = (TextView) listItemView.findViewById(R.id.event_distance);
distanceTextView.setText(currentEvent.getEventDistance());
TextView priceTextView = (TextView) listItemView.findViewById(R.id.event_price);
priceTextView.setText(currentEvent.getEventPrice());
ImageView thumbImgView = (ImageView) listItemView.findViewById(R.id.event_thumb);
thumbImgView.setImageResource(currentEvent.getEventThumb());
TextView confirmedGestsTextView = (TextView) listItemView.findViewById(R.id.confirmes_event_gests);
confirmedGestsTextView.setText(currentEvent.getConfirmedGuests());
}
return listItemView;
}
}