-1
我想要插入图像到linearlayout这是在dialog.But内运行应用程序时,我得到了空指针异常错误。 我想知道如何获取对话框中的视图对象。引起︰java.lang.NullPointerException︰尝试调用虚拟方法
这里是我的代码里面的oncreate函数。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_compinfo);
dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.activity_compinfopopup);
dialog.getWindow().getAttributes().width = AbsListView.LayoutParams.MATCH_PARENT;
dialog.getWindow().getAttributes().height = AbsListView.LayoutParams.WRAP_CONTENT;
dialog.show();
myGallery = (LinearLayout) findViewById(R.id.mygallery);
myGallery.addView(insertPhoto("http://www.a.com/demos/img/home/01.jpg"));
myGallery.addView(insertPhoto("http://www.a.com/demos/img/home/02.jpg"));
myGallery.addView(insertPhoto("http://www.a.com/demos/img/home/02.jpg"));
myGallery.addView(insertPhoto("http://www.a.com/demos/img/home/02.jpg"));
}
请帮
你想添加这些imageView到你的对话框? –
你可以发布你的XML吗? –
是的我想将图像添加到对话框内的线性布局 – Ashish