6

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?

Macarse
  • 91,829
  • 44
  • 175
  • 230
wetwork
  • 113
  • 1
  • 1
  • 9

3 Answers3

5

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.

Community
  • 1
  • 1
Macarse
  • 91,829
  • 44
  • 175
  • 230
5

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();
Amir Raminfar
  • 33,777
  • 7
  • 93
  • 123
  • `mContext = getApplicationContext();` causes exception. Use `YourActivity.this` instead as I believe this is a reported bug – Onimusha Sep 30 '15 at 14:12
0

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

Alxandr
  • 12,345
  • 10
  • 59
  • 95