如何打开一个弹出窗口的活动? [英] How to open an activity in a popup window?

查看:131
本文介绍了如何打开一个弹出窗口的活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ListActivity ,显示的产品清单。我prepared另一个布局为包含的项目的姓名,地址,电话号码和图像的详细视图。我想说明这些项目的详细在弹出窗口中,如果一个点击不关闭我的 ListActivity

I have a ListActivity which shows list of items. I prepared another layout for detailed view that contains items' name, address, phone number and image. I want to show these items detailed in a popup window if one is clicked without closing my ListActivity.

我怎样才能做到这一点?

How can i do that?

推荐答案

您可以使用AlertDialog来做到这一点。看看这里<一href="http://developer.android.com/guide/topics/ui/dialogs.html">http://developer.android.com/guide/topics/ui/dialogs.html.并滚动到创建自定义对话框。示例如下:

You can use AlertDialog to do this. Look here http://developer.android.com/guide/topics/ui/dialogs.html. And scroll to Creating a Custom Dialog. Example is:

AlertDialog.Builder builder;
AlertDialog alertDialog;

Context mContext = getApplicationContext();
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_dialog,
                               (ViewGroup) findViewById(R.id.layout_root));

TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("Hello, this is a custom dialog!");
ImageView image = (ImageView) layout.findViewById(R.id.image);
image.setImageResource(R.drawable.android);

builder = new AlertDialog.Builder(mContext);
builder.setView(layout);
alertDialog = builder.create();

这篇关于如何打开一个弹出窗口的活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆