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

  • Home
  • SEARCH
  • 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 9043645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:46:42+00:00 2026-06-16T10:46:42+00:00

I have a surfaceview that opens an alertdialog with an inflated layout, I want

  • 0

I have a surfaceview that opens an alertdialog with an inflated layout, I want to use an image onclicklistener on an imageview from this layout, but i get a nullpointerexception whenever I try to load the dialog, this happens when i set the onclicklistener to the imageview ‘tweet’. If i delete the listener it will load without errors. Below is my code

      activity.runOnUiThread(new Runnable(){

                public void run() {
                    AlertDialog.Builder adb = new AlertDialog.Builder(Panel.this.context);

                     try{ 
                         LayoutInflater inflater = ((Activity) context).getLayoutInflater(); 
                        View dialoglayout = inflater.inflate(R.layout.activity_anime_action, null);


                       adb.setView(dialoglayout)
                       .setNegativeButton("Done", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                Intent myIntent = new Intent(context, ActivityOne.class);
                                myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                                context.startActivity(myIntent);
                                ((Activity) context).finish(); 
                                dialog.cancel(); 
                            }
                        }); 
                           ImageView tweet = (ImageView)((Activity) context).findViewById(R.id.dialog_tweet);
                           tweet.setOnClickListener(new View.OnClickListener() {

                            public void onClick(View v) {
                                Log.d(VIEW_LOG_TAG, "WORKD");

                            }
                            });
                       }catch(Exception e){Log.d("INFLATER ERROR", e.toString());}
                    adb.show(); 





                }});
  • 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-16T10:46:43+00:00Added an answer on June 16, 2026 at 10:46 am

    You should be finding the ImageView from dialogLayout instead, since that is the Dialog’s layout you’re working with.

    Updated code should be:

    ImageView tweet = (ImageView) dialoglayout.findViewById(R.id.dialog_tweet);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML layout and want to add my own custom SurfaceView to
HI! I have a surfaceView inside a horizontal scrollview that I want to fill
I have a custom SurfaceView that looks like this: public class GFXSurface extends Activity
So basically I have an Activity with a layout that shows my custom SurfaceView
Have been looking on some tutorials for drawing canvas using SurfaceView, but the only
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
I want to add video in my app . But i have a problem
I have write this code to open the front camera on surfaceview in the
The scenario is the following: I have an activity RunTrainingWorkoutsView that uses XML layout
I have a SurfaceView that I draw onto, there are no controls, text boxes

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.