Basically, I have this LazyList which originally created by [Fedor][1] , I am just wondering if there is anyway to put it inside a dialog. Please help me, I've been struggling for days trying to figure this out, I really need your help. Thanks in advance!
Here his code when you need it:
p
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?&开发者_运维百科gt; arg0, View arg1, int position,long id) {
if(position == 0){
final Dialog dialog = new Dialog(MainPictures.this, R.style.CustomDialogTheme);
dialog.setContentView(R.layout.customlayout);
dialog.setTitle(null);
dialog.setCancelable(true);
dialog.show();
WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
lp.dimAmount=0.5f;
dialog.getWindow().setAttributes(lp);
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
}
else {
System.out.println("Error");
}
}
});
}
private String[] mStrings={
"http://www.urlurl/hi.png",
"http://www.urlurl/hi.png",
};
}
have a lokk at this.
http://developer.android.com/guide/topics/ui/dialogs.html
Update:
Another solution could be Create an ACtivity and Put listView in it and make its Theme as Dialog.
read this to know how to set theme http://developer.android.com/guide/topics/ui/themes.html
You have to create a dialog with a custom layout. So for example, use this layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="400dip"
android:padding="10dp">
<ListView android:id="@+id/MyAwesomeList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
And use it for a dialog like this when you're creating the dialog in the onCreateDialog() callback of your Activity:
Context mContext = getApplicationContext();
Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("Custom Dialog");
ListView myList = (ListView) dialog.findViewById(R.id.MyAwesomeList);
// set the list adapter and stuff
精彩评论