Back to project page game_guess_lib.
The source code is released under:
MIT License
If you think the Android project game_guess_lib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.wkmf.guess.lib.common.dialog; /*w ww.j a v a2 s . c om*/ import android.app.Dialog; import android.content.Context; import android.view.Window; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import com.wkmf.guess.lib.R; import java.util.ArrayList; import java.util.List; public class DialogModal { //propiedades private Context context; //lista de elementos que se mostrar private List<DialogElement> elements = new ArrayList<DialogElement>(); //dialog private Dialog dialog; //constructores public DialogModal(Context context){ this.context = context; initialize(); } public DialogModal(Context context, List<DialogElement> elements){ this.context = context; this.elements = elements; initialize(); } //inicializamos objeto private void initialize(){ dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_modal_help); dialog.setCanceledOnTouchOutside(true); } //mtodo para aadir un elemento public void addElement(DialogElement element){ this.elements.add(element); } //mtodos para mostrar el dialog public void show(OnItemClickListener onClick){ //preparamos la lista final ListView dialogList = (ListView)dialog.findViewById(R.id.dialog_modal_list); //seteamos el adaptador dialogList.setAdapter(new DialogModalListAdapter(this.context, elements)); //seteamos la accion dialogList.setOnItemClickListener(onClick); //mostramos el dialogo dialog.show(); } public void show(OnItemClickListener onClick, List<DialogElement> extraElements){ //preparamos la lista extra final ListView extraDialogList = (ListView)dialog.findViewById(R.id.dialog_modal_list_extra); //seteamos el adaptador extraDialogList.setAdapter(new DialogModalListAdapter(this.context, extraElements)); //seteamos la accion extraDialogList.setOnItemClickListener(onClick); //lanzamos la comn show(onClick); } //cerramos public void dismiss(){ dialog.dismiss(); } }