将图像从ListView传递到OnClick活动

时间:2019-03-26 09:33:31

标签: image

我正在尝试将数据从ListView传递到OnClick Activity,但我只知道如何传递String数据,你们可以帮我处理Image数据吗?我为图片使用byte [],如果有任何建议,请给我建议。

AuctionList.java:

mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Model e = mList.get(position);


            String name = e.getName();
            String description = e.getDescription();
            String price = e.getPrice();
            String duration = e.getDuration();
            //byte[] image = e.getImage();
            Intent intent5 = new Intent(AuctionList.this,BuyerHome.class);
            intent5.putExtra("name",name);
            intent5.putExtra("description",description);
            intent5.putExtra("price",price);
            intent5.putExtra("duration",duration);
            //intent5.putExtra("image",image);

            startActivity(intent5);
        }
    });

BuyerHome.java:

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

Bundle bundle = getIntent().getExtras();

    String name = bundle.getString("name");
    String duration = bundle.getString("duration");
    String price = bundle.getString("price");



    TextView durationLog = (TextView)findViewById(R.id.text_view_countdown);
    TextView priceLog = (TextView)findViewById(R.id.textPrice);
    TextView nameLog = (TextView)findViewById(R.id.txtItemName);
    TextView pricelog2 = findViewById(R.id.tvPrice);


    durationLog.setText(duration);
    priceLog.setText(price);
    nameLog.setText(name);
    pricelog2.setText(price);

}

0 个答案:

没有答案