簡體   English   中英

如何傳輸數據新意圖

[英]How can I transfer data new intent

我的 Onbindview 支架

    Glide.with(holder.t1.getContext())
            .load("http://example/example/images/" +data.get(position).getImage()).into(holder.img);
}

還有我的界面

itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (iOtobusSaatleriInterface != null){
                    int position = getAdapterPosition();
                    if (position != RecyclerView.NO_POSITION);
                    iOtobusSaatleriInterface.onItemClick(position);
                    Intent intent = new Intent(context,deneme.class);
                    intent.putExtra("name",data.get(position).getName());
                    intent.putExtra("resim", String.valueOf(Glide.with(itemView)
                            .load("http://example/example/images/")));
                    
                    context.startActivity(intent);
                }
            }
        });

我的新活動

Intent intent = getIntent();
    String name = intent.getStringExtra("name");
    int goruntu = intent.getIntExtra("resim",0);
    imageView.setImageResource(goruntu);
    textView.setText(name);

最后我的照片不來了。 我只是無法在新活動中獲取圖像數據。 此數據已在 mysql 中注冊,我正在從目錄中提取並進行改造。

新顯示器

我的圖像視圖顯示

還有我的xml

您可以將圖像作為字符串從屏幕 A 傳遞到屏幕 B。

在不了解您為何嘗試在活動之間通過 IPC 發送光柵圖像的更多信息的情況下,我認為我能給您的最佳建議是不要嘗試這樣做。

相反,只需發送意圖中的 URL 並讓 Activity 2 使用 glide 加載和顯示圖像。

擊球手的方法是將意圖中的完整 URL 作為字符串傳遞並在另一個 Activity 上接收它。

Intent intent = new Intent(context,deneme.class);
                    intent.putExtra("name",data.get(position).getName());
                    intent.putExtra("resim","YOUR_FULL_URL");

在另一個活動中

    Intent intent = getIntent();
        String name = intent.getStringExtra("name");
        String goruntu = intent.getStringExtra("resim");
    
String.valueOf(Glide.with(imageView)
                            .load(goruntu)
        textView.setText(name);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM