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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:17:30+00:00 2026-06-07T06:17:30+00:00

1.This is add button, when I click here I should arise custom dialog box.

  • 0

1.This is add button, when I click here I should arise custom dialog box.

Button add = (Button) findViewById(R.id.addbutton);
// add button listener
add.setOnClickListener(new OnClickListener() {

2.This is custom dialog box code

    // custom dialog
    final Dialog dialog = new Dialog(context);
    dialog.setContentView(R.layout.form);
    dialog.setTitle("Custom dailog");

    TextView uname_TV = (TextView) findViewById(R.id.Uname_TV);
    EditText uname_ET = (EditText) findViewById(R.id.Uname_ET);
    TextView dname_TV = (TextView) findViewById(R.id.Drugname_TV);
    EditText dname_ET = (EditText) findViewById(R.id.Drugname_ET);
    spinner = (Spinner) findViewById(R.id.spinner_id);

    ArrayAdapter < String > adapter = new ArrayAdapter < String > (
    context, android.R.layout.simple_spinner_item,
    noof_times);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setSelection(1);
    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView <? > parent,
        View view, int position, long id) {
            String item = parent.getItemAtPosition(position).toString();
            String item1 = parent.getSelectedItem().toString();
            Toast.makeText(getApplicationContext(), "Selected:" + item, Toast.LENGTH_LONG).show();
        }

        @Override
        public void onNothingSelected(AdapterView <? > arg0) {
            // TODO Auto-generated method stub
        }
    });
    dialog.show();

I am getting

  Null pointer exception at spinner.setAdapter(adapter);

I didn’t get it, one help out of this error

  • 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-07T06:17:32+00:00Added an answer on June 7, 2026 at 6:17 am

    It should be

    spinner = (Spinner) dialog.findViewById(R.id.spinner_id);
    

    Try with this line..hope it will work.

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

Sidebar

Related Questions

If we add event listener to a button in java like this : btn.setOnClickListener(new
This code works anywhere else.. form load, button click, etc. But when I add
I am trying to add a custom UIBarButtonItem to my navigationItem. This button will
So I wrote the code below: jQuery('#contentWrapper').delegate(.addButton, click, function(){ addRow(jQuery(this)); }); function addRow(thisButton){ var
I have an add this button on the website that is rendering a border
i add this script to my page it is a poll contain a button
I've got a button on my page in code behind I do this: btnSaveLineItems.Style.Add(display,
I add my page top link button like this: <a name=top></a> . . .
I need to position this update button on www.euroworker.no/order (you'll have to add an
I'm starting to learn Backbone with this simple example: <div id=counter>unkown</div> <button id=add-button>ADD</button> (function($){

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.