Custom ListView inside a dialog in android

前端 未结 3 1517
北荒
北荒 2021-01-26 13:03

I am trying to make a custom dialog with listview which is going to contain checkboxes and textviews and i just couldnt find a reasonable tutorial to do it , any help or hints w

3条回答
  •  不要未来只要你来
    2021-01-26 14:03

    private void showPopUp()
    {
        final AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this);
        helpBuilder.setTitle("");
    
        LayoutInflater inflater = getLayoutInflater();
        final View PopupLayout = inflater.inflate(R.layout.yourxml, null);
        helpBuilder.setView(PopupLayout);
    
        final AlertDialog helpDialog = helpBuilder.create();
        helpDialog.show();
    
        jobList         =   (ListView)PopupLayout.findViewById(R.id.list);
    
        mylist          =   new ArrayList>();
    
        for(int i=0;i();
            map.put("name", arraylist.get(i));
            mylist.add(map);
        }
        sd = new SimpleAdapter(activity.this,mylist,R.layout.jobslist,
                    new String[]{"name"},new int[]{R.id.jobText});
        jobList.setAdapter(sd);
    
    
    }
    

    joblist.xml

    
    
    
            
    
            
    
    
            
    

    you can call this showPopUp(); function wherever you want to display the alert dialog with listview. please note that there will be the arraylist which you can add items to it to show the items in a list

提交回复
热议问题