简体   繁体   中英

How make alert dialog pointing from a button on click of button?

I'm having a requirement where i need to display some as below.

AlertDialog

But i'm as shown below.

CurrentDialog

The code that i'm using to get the above dialog is as below.

ListView visitsListView = (ListView) vg.findViewById(R.id.lvDayRemindersList);
        //if ( visitsListView == null ) return;
        TextView noVisitDayTextView = (TextView) vg.findViewById(R.id.no_visits_day);
        if ( visitsListView == null && day != null )
        {
            //activityListDialog = new AlertDialog(vg.getContext());
            LayoutInflater li = (LayoutInflater) vg.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View v = li.inflate(R.layout.cal_month_day_list_view, null, false);
            visitsListView = (ListView) v.findViewById(R.id.today_list_view);
            //noVisitDayTextView = (TextView) vg.findViewById(R.id.today_list_view_title);
            //activityListDialog.setContentView(v);
            AlertDialog.Builder builder = new AlertDialog.Builder(vg.getContext());
            builder.setTitle(day);
            builder.setView(v);
            activityListDialog = builder.create();
            activityListDialog.setCanceledOnTouchOutside(true);
        }

On click of the grid i'm calling the dialog as shown below.

if (isContainsData && isOnSelected) 
        {
            Logger.performanceLogEnd("CalendarMonthView-displayVisitListDialog");
            activityListDialog.show();
        } 

Could someone please help in achieving this. Thank you.

One thing I notice is that there is no code for filling up the content of object visitsListView . At least I don't see the code. visitsListView is being used twice from calling findViewById (), and that is confusing.

Perhaps it is good if you post the xml layout cal_month_day_list_view and others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM