Reputation: 2806
i want use popup . i wrote a piece of code using intent i want to convert it to popup.
here is my code below :
ArrayList<String> contactList = new ArrayList<String>();
switch (reqCode) {
case (0):
if (resultCode == Activity.RESULT_OK) {
Uri contactData = data.getData();
Cursor c = getContentResolver().query(contactData, null, null,
null, null);
if (c.moveToFirst()) {
String name = c
.getString(c
.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
String phoneNumber = c
.getString(c
.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
String contact = name + phoneNumber;
contactList.add(contact);
}
}
break;
}
Intent intent = new Intent(IndexActivity.this, OrderActivity.class);
intent.putStringArrayListExtra("Contacts", contactList);
startActivity(intent);
}
Upvotes: 1
Views: 92
Reputation: 79
//Below code will help you..
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("Contacts");
builder.setAdapter(new ContactListAdapter(),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String contact = contactList.get(which);
Log.e("onClick", "Selected contact " + contact);
}
});
builder.setNegativeButton("cancel",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
Log.d(DEBUG_TAG, "AlertDialog.show");
Upvotes: 0
Reputation: 17580
Create your activity as a Dialog
<activity
android:name="OrderActivity"
android:theme="@android:style/Theme.Dialog"
android:excludeFromRecents="true"
>
</activity>
and for removing title of the Activity Dialog- write this before setcontentview-
requestWindowFeature(Window.FEATURE_NO_TITLE);
Upvotes: 1