Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8067175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:12:32+00:00 2026-06-05T12:12:32+00:00

With ref to my previous question in button not shown in alertDialog I am

  • 0

With ref to my previous question in button not shown in alertDialog

I am creating a class which extends AlertDialog. In the class I am setting the content from xml which has buttons, but my button is not responding. my custom alert java file is

public class DateTimeDialog extends AlertDialog{

    Date date;
    String title;
    View.OnClickListener listner;
    protected DateTimeDialog(Context context, String title, Date date ) {
        super(context, android.R.style.Theme_Holo_Light_Dialog);
        // TODO Auto-generated constructor stub
        this.title = title;
        this.date = date;
    }

    public void initListener(View.OnClickListener listner){
        this.listner = listner;
    }

    @Override
    public void onCreate(Bundle savedInstanceState){
        //super.onCreate(savedInstanceState);
        setContentView(R.layout.date_time_picker);

        setTitle(title);

        Button dialogButtonOK = (Button) findViewById(R.id.btn_ok);
        // if button is clicked, close the custom dialog
        dialogButtonOK.setOnClickListener(listner);

        Button dialogButtonCancel = (Button) findViewById(R.id.btn_cancel);
        // if button is clicked, close the custom dialog
        dialogButtonCancel.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View dialog) {
                // TODO Auto-generated method stub

            }
        });


    }

My method calling this class is

final DateTimeDialog dateTimeDialog = new DateTimeDialog(context, "Title", date);
           dateTimeDialog.show();
           dateTimeDialog.initListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    //done something
                }
            });

problem is my ok button is not called when clicked but cancel is called.
I don’t know where i am getting wrong.Please help!!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:12:34+00:00Added an answer on June 5, 2026 at 12:12 pm

    Try this:

    public void initListener(View.OnClickListener listner){
        this.listner = listner;
        Button dialogButtonOK = (Button) findViewById(R.id.btn_ok);
        dialogButtonOK.setOnClickListener(listner);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Previous question which links onto this and has any addition code ref should I
I have some question about functions which have default parameters. import sys from random
public ref class ScriptEditor : public Form { public: typedef map<UInt32, ScriptEditor^> AlMap; static
This is a follow-on question to C++0x rvalue references and temporaries In the previous
I think I tried to ask for far too much in my previous question
This a follow-up to a previous question . How can I optimize this query
In my previous question (regarding adding items to ArrayList) one of the posters wrote
I'm very sorry for my previous miswording. So I rephrased this question as follows:
As an extension to my previous question , I would like to automatically select
To my previous question about segmentation fault ,I got very useful answers.Thanks for those

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.