Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open an activity in a popup window?

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?

like image 259
wetwork Avatar asked Jan 26 '11 14:01

wetwork


People also ask

What is pop-up activity?

The Pop up activities course format displays resources and simple activities embedded in modals instead of redirecting from the course page.

How do I open a pop-up window on Android?

Use setWidth(int) and setHeight(int) . Set the layout type for this window. Display the content view in a popup window anchored to the bottom-left corner of the anchor view. Displays the content view in a popup window anchored to the corner of another view.

How do I create a popup menu?

Go to app > res > right-click > New > Android Resource Directory and give Directory name and Resource type as menu. Now, we will create a popup_menu file inside that menu resource directory. Go to app > res > menu > right-click > New > Menu Resource File and create a menu resource file and name it as popup_menu.


2 Answers

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();
like image 200
Amir Raminfar Avatar answered Sep 24 '22 03:09

Amir Raminfar


You can use a quickAction like the Twitter app or start a new Activity with android:theme="@android:style/Theme.Dialog" specified in your manifest.

like image 44
Macarse Avatar answered Sep 24 '22 03:09

Macarse