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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:16:24+00:00 2026-06-01T10:16:24+00:00

I have a function to show Dialog. public Dialog sendSMS(){ Dialog dialog = new

  • 0

I have a function to show Dialog.

public Dialog sendSMS(){
        Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.dialogsms);
        dialog.setTitle("Send SMS");
        dialog.setCancelable(true);

        final Spinner spn = (Spinner)findViewById(R.id.spn_contatcs);
        final TextView tenso = (TextView)findViewById(R.id.txt_phone);

        final ArrayList<String> ten = new ArrayList<String>();
        final ArrayList<String> so = new ArrayList<String>();

        Cursor phones = _ketquatimkiem.this.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null,null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " ASC");
        while (phones.moveToNext()){
                String phoneName=phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
                String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                ten.add(phoneName);
                so.add(phoneNumber);
            }
        phones.close();

        ArrayAdapter<String> arrayAdapter_Contacts = new ArrayAdapter<String>(_ketquatimkiem.this,android.R.layout.simple_spinner_item,ten);
        arrayAdapter_Contacts.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spn.setAdapter(arrayAdapter_Contacts);
        spn.setOnItemSelectedListener(new OnItemSelectedListener(){
            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3) {
                tenso.setText("Phone Num:  "+so.get(arg2).toString());  
            }
            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
            }
        });
        return dialog;
    }

Call in onCreate()

//when i click item of listview i get quickactiondialog    
listView.setOnItemClickListener(new OnItemClickListener(){
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
        final QuickActionDialog quickAction = new QuickActionDialog(arg1.getContext(), QuickActionDialog.VERTICAL);   
        //when click item of quickactiondialog id == sms i show dialog 
        quickAction.setOnActionItemClickListener(new QuickActionDialog.OnActionItemClickListener() {        
            @Override
            public void onItemClick(QuickActionDialog source, int pos, int actionId) {                                      
                if(actionId == ID_SMS){
                    Dialog dialog= sendSMS();
                    dialog.show();
                }
            }
        });

But i get error: E/AndroidRuntime(15562): java.lang.NullPointerException at spn.setAdapter(arrayAdapter_Contacts);

I test on real device ss gt-5570. Sorry i use english not good 🙁

  • 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-01T10:16:25+00:00Added an answer on June 1, 2026 at 10:16 am

    In your sendSMS() method you are accessing the layout of your Activity

    final Spinner spn = (Spinner)findViewById(R.id.spn_contatcs);
    

    That must be null because your Activity layout does not contain the Spinner. You have to do something like the following (see content.findViewById)

    Dialog dialog = new Dialog(this);
    View content = View.inflate(this, R.layout.dialogsms, null);
    // your contact stuff
    Spinner spn = (Spinner) content.findViewById(R.id.spn_contatcs);
    spn.setAdapter(arrayAdapter_Contacts);
    dialog.setContentView(content);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code like this public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); boolean autoLogin
I have a custom dialog that I set up as a function: public void
I have a function called show which shows a dialog with the message. I
I have this function: show_employee_table() -> do(qlc:q([B || B <- mnesia:table(employee)])). What it does
I have the following code: function show(){ var a=document.getElementById('somediv').style.display; a=block; } The above code
Imagine I have a class Window with a member function show which causes the
I have a javascript function that will show the image you're about to upload
i have an application class inherited from QtGui.QDialog. I have to reload show-function but
I have a div show hide function which is working fine. when I click
I have added the following fine function to my status bar to show which

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.