我正试图从回收器视图图像点击打开一个对话框...该对话框包含一个视图页来创建一个滑动视图库..
holder.image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Dialog dialog = new Dialog(holder.itemView.getContext());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCanceledOnTouchOutside(false);
dialog.setCancelable(true);
dialog.setContentView(R.layout.activity_fullscreen_image);
ImageView back=(ImageView)dialog.findViewById(R.id.back);
ViewPager viewPagerPhotoSlideShow = (ViewPager) dialog.findViewById(R.id.pager);
ArrayList<String> pagerListItems=new ArrayList<String>();
pagerListItems.add(0,"https://firebasestorage.googleapis.com/v0/b/zumi-60a8f.appspot.com/o/Chat_Images%2Fcropped-1222406361.png?alt=media&token=22b8673f-5602-48d4-980f-986d505d2d8f");
pagerListItems.add(1,"https://firebasestorage.googleapis.com/v0/b/zumi-60a8f.appspot.com/o/Chat_Images%2Fcropped1611377016.png?alt=media&token=e7a40c6c-35ad-48ee-80ca-656384fcf68c");
FullScreenImageAdapter adapterPhotoViewPager = new FullScreenImageAdapter(dialog.getOwnerActivity(), pagerListItems);
viewPagerPhotoSlideShow.setAdapter(adapterPhotoViewPager);
viewPagerPhotoSlideShow.setCurrentItem(0);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.cancel();
}
});
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.MATCH_PARENT;
lp.gravity = Gravity.CENTER;
Window window = dialog.getWindow();
window.setAttributes(lp);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();
}
});
public class FullScreenImageAdapter extends PagerAdapter {
private Activity _activity;
private ArrayList<String> _imagePaths;
private LayoutInflater inflater;
// constructor
public FullScreenImageAdapter(Activity activity,
ArrayList<String> imagePaths) {
this._activity = activity;
this._imagePaths = imagePaths;
}
@Override
public int getCount() {
return this._imagePaths.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == ((RelativeLayout) object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
ImageView imgDisplay;
// Button btnClose;
inflater = (LayoutInflater) _activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View viewLayout = inflater.inflate(R.layout.layout_fullscreen_image_each, container,
false);
imgDisplay = (ImageView) viewLayout.findViewById(R.id.imgDisplay);
Glide.with(container.getContext()).load(_imagePaths.get(0))
.priority(Priority.HIGH).animate(android.R.anim.fade_in)
.override(120, 87).fitCenter().skipMemoryCache(false)
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.into(imgDisplay);
((ViewPager) container).addView(viewLayout);
return viewLayout;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
((ViewPager) container).removeView((RelativeLayout) object);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/arrow"
android:rotation="180"
android:id="@+id/back"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imgDisplay"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter" />
</RelativeLayout>
错误>>>
E/AndroidRuntime:致命异常:main process:com.example.cosmic.zumi_test,pid:22289 java.lang.nullpointerException:试图在Android.support.v4的Android.support.v4的Android.cosmic.zumi_test.from(layoutInflater.java.219)和Android.support.v4.view.viewpager.addnewitem(viewpager.java:1034)上的空对象引用上调用虚拟方法'java.lang.object在Android.support.v4.view.view.viewpager.populate(ViewPager.java:1182),在Android.support.v4.view.viewPager.populate(ViewPager.java:1116),在Android.support.v4.view.viewPager.onMeasure(ViewPager.java:1642)在Android.view.view.viewPager.onMeasure(ViewPager.java:1642),在Android.view.view.viewGroup.Measure奥尼梅苏在Android.view.view.measur(view.java:17572),在Android.view.viewgroup.measureChildWithMargins(viewgroup.java:5604),在Android.widget.frameLayout.onMeasur(frameLayout.java:436),在Android.view.viewgroup.measureChildWithMargins(viewgroup.java:436,在Android.view.viewgroup.measureChildWithMargins(:5604)在Android.widget.frameLayout.onMeasure(frameLayout.java:436)在com.android.internal.policy.impl.phoneWindow$decorview.onMeasure(phoneWindow.java:2632)在Android.view.view.view.measure(view.java:17572)在Android.view.viewrootimpl.measure(view.java:1752)在Android.view.viewrootimpl.measure(view.java:1173在Android.view.ViewRootimpl$traversalrunnable.run(viewrootimpl.java:5895)在Android.view.choreographer$CallbackRecord.run(choreographer.java:767)在Android.view.choreographer.docallbacks(choreographer.java:580)在Android.view.choreographer.java:550)在Android.view.choreographer.doFrame(choreographer.java:550)在id.os.looper.loop(looper.java:135),地址为Android.app.activitythread.main(activitythread.java:5345),地址为java.lang.reflect.Method.invoke(本机方法),地址为java.lang.reflect.Method.invoke(Method.java:372),地址为com.android.internal.os.zygoteinit.run(zygoteinit.jam(zygoteinit.java:742)。
似乎_activity
在FullScreenImageAdapter
中为空。这是因为dialog.getowneractivity()
是null(正如@dipdipdip所说)。不要像您那样实例化视图分页程序适配器,请尝试这样做:
FullScreenImageAdapter adapterPhotoViewPager = new FullScreenImageAdapter(v.getContext(), pagerListItems);
更新
若要在对话框中显示不同的图像,请按以下方式更改页适配器中的InstantiateItem
方法:
@Override
public Object instantiateItem(ViewGroup container, int position) {
ImageView imgDisplay;
// Button btnClose;
inflater = (LayoutInflater) _activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View viewLayout = inflater.inflate(R.layout.layout_fullscreen_image_each, container,
false);
imgDisplay = (ImageView) viewLayout.findViewById(R.id.imgDisplay);
Glide.with(container.getContext()).load(_imagePaths.get(position))
.priority(Priority.HIGH).animate(android.R.anim.fade_in)
.override(120, 87).fitCenter().skipMemoryCache(false)
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.into(imgDisplay);
((ViewPager) container).addView(viewLayout);
return viewLayout;
}
我想通过Remote tecommand操作打开一个对话框,并从页面后备bean中的中获取值。远程命令在页面加载时正确触发bb中的actionListener 使用此show Dialog方法也可以正确显示对话框: 在另一个Bean中: 问题是,我不知道如何聆听由以下事件引发的事件: 在PF示例中http://www.primefaces.org/showcase/ui/dialogFramewo
问题内容: 我正在开发一个程序,该程序可以从文本文件加载和保存数据,并且正在询问用户加载和保存JFileChooser的文件名。 这个问题与 保存 对话框有关:。然后,用户可以在没有任何警告的情况下覆盖现有文件,这 将是一个问题 。 关于如何解决此问题的任何建议?我一直在寻找某种方法或选项,但没有发现任何东西。 提前致谢。 问题答案: 感谢您提供答案,但是我发现了另一个解决方法,可以用这种方法覆盖
Java代码: 我已经通过许多在线链接,但都显示如何在edittext中设置日期,但我想要的是相反的。edittext中有一个值,datepicker对话框将打开,该日期将作为预选值。
我有一个模态,页眉和页脚是粘性的,中间部分是基于内容滚动的。 在桌面上,它的工作非常好,但在移动和平板电脑上,页脚被拉伸,没有显示100%。 我希望实现高度响应对话框与页眉/页脚粘性和内容部分滚动。 我在这里做错了什么? null null
Jquery Mobile支持包含历史回退按钮的自动ajax读取外部页面的功能,一组页面转场动画,以及将页面显示为对话框的简易工具。
本文向大家介绍sharepoint 在对话框中显示现有页面,包括了sharepoint 在对话框中显示现有页面的使用技巧和注意事项,需要的朋友参考一下 示例