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 6640625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:41:41+00:00 2026-05-25T23:41:41+00:00

I have made a main Dialog class on which I send the layout ID

  • 0

I have made a main Dialog class on which I send the layout ID and shows the layout as a Dialog now when I send the layout from calling class it pops up the dialog but the contents of dialog i.e. buttons are inaccessible I can’t set click listener for them. How to do that?

CALLING CLASS:-

CustomDialog obj=new CustomDialog(MailSenderActivity.this , R.layout.mydialog);
obj.show();

MAIN CLASS

import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class CustomDialog extends Dialog implements
View.OnClickListener {
    Dialog dialog;
    int id;


    public CustomDialog(MailSenderActivity mailsender, int id) {
        super(mailsender);
        this.id = id;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(id);



        Button signInbutton=(Button)findViewById(R.id.signInButton);

        Button closebutton=(Button)findViewById(R.id.closeButton);




        }






    public void closebutton(View v) {
        Toast.makeText(getContext(), "You clicked a button!", Toast.LENGTH_LONG).show();
        dismiss();

    }

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

    }
}

id is:-

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent" android:layout_width="fill_parent"
    android:padding="30dip" android:orientation="horizontal"
    android:weightSum="1"
    android:background="@drawable/gmail">
    <LinearLayout android:layout_width="296dp"
        android:orientation="vertical" android:layout_gravity="center"
        android:layout_weight="1.51" android:layout_height="497dp">
        <TextView android:text="My Dialog" android:textSize="24.5sp"
            android:layout_width="wrap_content" android:layout_gravity="center"
            android:layout_height="wrap_content" android:layout_marginBottom="25dip"></TextView>
        <TextView android:text="Enter Gmail Id" android:layout_width="fill_parent"
            android:layout_height="wrap_content"></TextView>
        <EditText android:id="@+id/name" android:layout_width="358dp"
            android:singleLine="true" android:layout_height="wrap_content">

        </EditText>
        <TextView android:text="Enter Gmail Password"
            android:layout_width="fill_parent" android:layout_height="wrap_content"></TextView>
        <EditText android:id="@+id/name" android:layout_width="314dp"
            android:singleLine="true" android:layout_height="wrap_content"
            android:password="false" android:inputType="textPassword"></EditText>
        <Button android:text="Sign In" android:layout_width="67dp"
            android:id="@+id/signInButton" android:layout_height="wrap_content"
            android:clickable="true" android:onClick="signIn"></Button>

        <Button android:text="close" android:layout_width="67dp"
            android:id="@+id/closeButton" android:layout_height="wrap_content"
            android:clickable="true" android:onClick="closeButton"></Button>
    </LinearLayout>
</LinearLayout>
  • 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-05-25T23:41:42+00:00Added an answer on May 25, 2026 at 11:41 pm

    There you go:

        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(id);
    
        Button signInbutton=(Button)findViewById(R.id.signInButton);
        signInButton.setOnClickListener(this);
        Button closebutton=(Button)findViewById(R.id.closeButton);
        closeButton.setOnClickListener(this);
        }
    
    @Override
    public void onClick(View v) {
        if(R.id.closeButton == v.getId()) { 
            closeButton(v);
        } else {
    
        // do the same for signInButton
        }
    
    }
    

    Suggest you learn the basic beforehand.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a class which a form can inherit from and it handles
I have made a secondary form in my project which can get data from
I have made an application in which there is a file main.c which uses
i have made an app that would calculate numbers from input fields. **main Activity
My question is, In my code I have made a JTable in main class.
From what I have played around with JQuery Dialog, I made an observation that
I have a main branch with a file called app.js . I made changes
I have made some code which exports some details of a journal article to
I have made a new windows service which works fine using barebone code (just
i have made a program to compute roots of quauation but it does not

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.