For this, you create a separate xml file (in the good folder, do new file, blank …) in which you create the wanted item, and you manage it in the java file:


List<ReceivedLog> logs = new ArrayList();
ListView logsListView;


private void populateList() {
    ArrayAdapter<ReceivedLog> adapter = new logListAdapter();

private void addLog(InetAddress ip, Date date, String log){
    logs.add(new ReceivedLog(ip, date, log));

private class logListAdapter extends ArrayAdapter{
    public logListAdapter() {
        super(MainActivity.this, R.layout.log_item, logs);

    public View getView(int position, View view, ViewGroup parent){
        if (view == null)
            view = getLayoutInflater().inflate(R.layout.log_item, parent, false);
        ReceivedLog currentLog = logs.get(position);

        TextView ip = (TextView) view.findViewById(;
        TextView date = (TextView) view.findViewById(;
        TextView log = (TextView) view.findViewById(;

        return view;


Back Next

Create android item list
Tagged on:         

2 thoughts on “Create android item list

Leave a Reply