Screen transition memorandum Information transfer from listview

Screen transition memorandum

・ Tap list view to change the screen ・ Move listview information

MainActivity

QuantityInfo info =list.get(position);

Get the position of the list

intent.putExtra("QuantityInfo", info);

QuantityInfo implements the QuantityInfo class in order to intent.putExtra the class → Can be stored in intent by serializing

    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        //Screen transition
        Intent intent = new Intent(getApplication(), DetailActivity.class);
        QuantityInfo info =list.get(position);
        intent.putExtra("QuantityInfo", info);
        startActivity(intent);

    }
}

SubActivity

QuantityInfo info = (QuantityInfo)getIntent().getSerializableExtra("QuantityInfo" );

When intenting, the serialized position of QuantityInfo and QuantityInfo is taken out in info.

time.setText(info.getTime());
comment.setText(info.getComment());
quantity.setText("" + info.getQuantity());

SetText the information in info

public class DetailActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detail);
        setTitle("");

        Intent intent = getIntent();
        //Receive value from MainActivity
        QuantityInfo info = (QuantityInfo)getIntent().getSerializableExtra("QuantityInfo" );

        //Applying id textView1 to t1
        TextView time = (TextView)findViewById(R.id.textView1);
        //Applying id textView1 to t2
        TextView comment = (TextView)findViewById(R.id.textView2);
        //Applying id textView1 to t3
        TextView quantity = (TextView)findViewById(R.id.textView3);

        //Show received value
        time.setText(info.getTime());
        comment.setText(info.getComment());
        quantity.setText("" + info.getQuantity());
    }
}

Succeeded in making the screen transition from selecting list Remaining items: Arrange the layout, let the image be selected, store in the list and redisplay.

Recommended Posts

Screen transition memorandum Information transfer from listview
Screen transition Information transfer memorandum
Screen transition memorandum
Screen transition method
JavaFX8 screen transition
How to transition from the [Swift5] app to the iPhone settings screen