我有一个RecyclerView列表项,其中包含小缩略图。我想以此为参考为同一缩略图(抽屉)加载更大尺寸的图像。我该如何实现?
也请随时建议我进行优化。那将帮助我学习得更好。
viewHolder.itemCardVIew.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(mContext, "Item Clicked " + place.getPlaceImage() + " / " + place.getPlaceTitle(), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(mContext, PlaceActivity.class);
intent.putExtra("place_image", place.getPlaceImage());
intent.putExtra("place_heading", place.getPlaceTitle());
intent.putExtra("place_content", place.getPlaceExcerpt());
mContext.startActivity(intent);
}
});
public class PlaceActivity extends AppCompatActivity {
private static final String TAG = "PlaceActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_place);
Log.d(TAG, "onCreate: started.");
getIncomingIntent();
}
private void getIncomingIntent() {
Log.d(TAG, "getIncomingIntent: checking for incoming intents.");
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
if (bundle != null) {
if (intent.hasExtra("place_image") && intent.hasExtra("place_heading") && intent.hasExtra("place_content")) {
int placeImage = bundle.getInt("place_image");
String placeHeading = bundle.getString("place_heading");
String placeContent = bundle.getString("place_content");
setActivityData(placeImage, placeHeading, placeContent);
}
}
}
private void setActivityData(int imageResource, String headingText, String contentText) {
ImageView placeImage = findViewById(R.id.place_single_image);
TextView placeHeading = findViewById(R.id.place_single_heading);
TextView placeContent = findViewById(R.id.place_single_content);
placeImage.setImageResource(imageResource);
placeHeading.setText(headingText);
placeContent.setText(contentText);
}
}