Reputation: 1185
I have an Activity containing a list of products using ListView. If I click on any product A than a dialog is opened and this product A is added into the dialog. To to add another Product B I want to scroll list of product while dialog is opened. But I am not able to scroll list.
Upvotes: 0
Views: 965
Reputation: 363
If you are looking to open the default android dailog LIstView with scroll .Here is some code sample which is working correctly.
AlertDialog.Builder builderSingle = new AlertDialog.Builder(DialogActivity.this);
builderSingle.setIcon(R.drawable.ic_launcher);
builderSingle.setTitle("Select One Name:-");
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(
DialogActivity.this,
android.R.layout.select_dialog_singlechoice);
arrayAdapter.add("Hardik");
arrayAdapter.add("Archit");
arrayAdapter.add("Jignesh");
arrayAdapter.add("Umang");
arrayAdapter.add("Gatti");
builderSingle.setNegativeButton(
"cancel",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builderSingle.setAdapter(
arrayAdapter,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String strName = arrayAdapter.getItem(which);
AlertDialog.Builder builderInner = new AlertDialog.Builder(
DialogActivity.this);
builderInner.setMessage(strName);
builderInner.setTitle("Your Selected Item is");
builderInner.setPositiveButton(
"Ok",
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
}
});
builderInner.show();
}
});
builderSingle.show();
Upvotes: 0
Reputation: 668
When you open a dialog, the view/activity in the back is uncontrollable. What you can do is add a View on top of the ListView and play with the setVisibility(View.***) method, which will display the contents of the dialog you wanted to show.
Upvotes: 1