Android加载完整图像Recyclerview Cardview [英] Android Load Full Image Recyclerview Cardview
问题描述
以下是我的recyclerview,它在所附的图像中使用php mysql和volley库.截至目前,当单击显示的图像时,将显示图像名称的吐司.是否可以加载完整的图像单击而不是吐司消息?预先谢谢你
The following is my recyclerview using php mysql and volley library in the attached image. As of now when one clicks the displayed image a toast of the image name appears as seen. Is it possible to load the full image click instead of the toast message?. Thank you in advance
主要活动
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageTitleNameArrayListForClick = new ArrayList<>();
ListOfdataAdapter = new ArrayList<>();
recyclerView = (RecyclerView) findViewById(R.id.recyclerview1);
recyclerView.setHasFixedSize(true);
layoutManagerOfrecyclerView = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManagerOfrecyclerView);
JSON_HTTP_CALL();
// Implementing Click Listener on RecyclerView.
recyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
GestureDetector gestureDetector = new GestureDetector(MainActivity.this, new GestureDetector.SimpleOnGestureListener() {
@Override public boolean onSingleTapUp(MotionEvent motionEvent) {
return true;
}
});
@Override
public boolean onInterceptTouchEvent(RecyclerView Recyclerview, MotionEvent motionEvent) {
view = Recyclerview.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
if(view != null && gestureDetector.onTouchEvent(motionEvent)) {
//Getting RecyclerView Clicked Item value.
RecyclerViewItemPosition = Recyclerview.getChildAdapterPosition(view);
// Showing RecyclerView Clicked Item value using Toast.
Toast.makeText(MainActivity.this, ImageTitleNameArrayListForClick.get(RecyclerViewItemPosition), Toast.LENGTH_LONG).show();
}
return false;
}
@Override
public void onTouchEvent(RecyclerView Recyclerview, MotionEvent motionEvent) {
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});
推荐答案
提取图像的完整路径,并将其放入变量中,如下所示:
extract full path of your image and put it in a variable, like this:
http://yourserver.com/path/to/your/image.jpg
然后将图像加载器库添加到您的项目中,例如 Glide 或
then add an image loader library to your project like Glide or Picasso
然后您可以在需要的任何位置加载图像.例如在警报对话框中加载.
then you can load your image any where you need. like loading in an alert dialog.
这篇关于Android加载完整图像Recyclerview Cardview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!