How to open activity in popup?

I have a ListActivity that shows a list of items. I prepared another layout for a detailed view, which contains the name, address, phone number and image. I want to show these items in detail in a popup if I click without closing ListActivity .

How can i do this?

+6
android android-activity layout
source share
3 answers

You can use AlertDialog for this. See http://developer.android.com/guide/topics/ui/dialogs.html . Go to the "Creating a Custom Dialog" section. Example:

 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(); 
+5
source share

You can use quickAction, for example, a Twitter application, or create a new Activity with android:theme="@android:style/Theme.Dialog" specified in your manifest.

+4
source share

Creating dialogs is described on this page: http://developer.android.com/guide/topics/ui/dialogs.html

0
source share

All Articles