小编gon*_*dev的帖子

如何在android中将图像从一个活动发送到另一个活动

主要活动

holder.cardView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
       String title = ((TextView) view.findViewById(R.id.recipe_title)).getText().toString();
       String time = ((TextView) view.findViewById(R.id.time)).getText().toString();
       String servings = ((TextView) view.findViewById(R.id.servings)).getText().toString();
       String calories = ((TextView) view.findViewById(R.id.calories)).getText().toString();
       ImageView thumbnail = (ImageView) view.findViewById(R.id.recipe_img);
       Intent intent = new Intent(context, ActivityDetail.class);
       intent.putExtra("RecipeTitle", title);
       intent.putExtra("RecipeTotalTime", time);
       intent.putExtra("RecipeServings", servings);
       intent.putExtra("RecipeCalories", calories);
       context.startActivity(intent);
    }
});
Run Code Online (Sandbox Code Playgroud)

详细活动

TextView time = (TextView)findViewById(R.id.time_detail);
TextView servings = (TextView)findViewById(R.id.servings_detail);
TextView calories = (TextView)findViewById(R.id.calories_detail);
ImageView thumbnail = (ImageView)findViewById(R.id.image_paralax);
time.setText(getIntent().getExtras().getString("RecipeTotalTime"));
servings.setText(getIntent().getExtras().getString("RecipeServings"));
calories.setText(getIntent().getExtras().getString("RecipeCalories"));
Run Code Online (Sandbox Code Playgroud)

如何将缩略图从第一个发送Activity到第二个Activity。在第二个“活动”中,缩略图将显示在 ImageView 上。

java android image send android-studio

2
推荐指数
1
解决办法
4844
查看次数

标签 统计

android ×1

android-studio ×1

image ×1

java ×1

send ×1