Main4Activity.java 1.52 KB
package com.example.ksi.refrigerator;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Layout;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.ArrayList;

public class Main4Activity extends AppCompatActivity {

    Intent intent;

    ArrayList<Item> itemList = new ArrayList();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main4);

        intent = getIntent();

        itemList = (ArrayList<Item>)intent.getSerializableExtra("item");

        LinearLayout layout = findViewById(R.id.layout);
        TextView item[][] =  new TextView[itemList.size()][2];

        for(int i=0; i< itemList.size();i++)
        {
            item[i][0] = new TextView(this);
            item[i][1] = new TextView(this);

            item[i][0].setText(itemList.get(i).name);
            item[i][0].setTextSize(20);
            Format formatter = new SimpleDateFormat("yyyy-MM-dd");
            String s = formatter.format(itemList.get(i).date);
            item[i][1].setText(s);
            item[i][1].setTextSize(20);


            LinearLayout layout2 = new LinearLayout(this);
            layout2.addView(item[i][0]);
            layout2.addView(item[i][1]);
            layout.addView(layout2);
        }




    }
}