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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:54:14+00:00 2026-06-06T20:54:14+00:00

Hello i use AVD and I don’t know how to error stack when I

  • 0

Hello i use AVD and I don’t know how to error stack when I get -> app stopped working force quit…

I wanted to code simple listener but there was an error -> i know that error is caused by setOnClick listener and this is probalby null pointer exception, but I would like to see it on stack error. Please tell me also why there is an exception. I attach the part of XML

package com.example.pierwsza;

 import android.os.Bundle;
 import android.app.Activity;
 import android.content.DialogInterface;
 import android.content.DialogInterface.OnClickListener;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.support.v4.app.NavUtils;

class MainActivity extends Activity implements OnClickListener{
Button b;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    b = (Button) findViewById(R.id.button3);
   // b.setOnClickListener((android.view.View.OnClickListener) this); <--- ERROR
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

public void onClick(DialogInterface dialog, int which) {
    //b.setText("Ale to dziwne");

}


}

XML of that BUTTON

 <Button
    android:id="@+id/button3"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/linearLayout1"
    android:layout_marginBottom="29dp"
    android:layout_toLeftOf="@+id/textView1"
    android:text="Jakis przycisk" />
  • 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-06T20:54:15+00:00Added an answer on June 6, 2026 at 8:54 pm

    If you are using Eclipse to code, go to Window -> Show View -> LogCat to see the error stack thrown by your app.

    To fix this particular error change this:

    public void onClick(DialogInterface dialog, int which) {
        //b.setText("Ale to dziwne");
    }
    

    To use a View.OnClickListener() like this:

    public void onClick(View view) {
        //b.setText("Ale to dziwne");
    }
    

    And press Ctrl+Shift+O to update your import statements from DialogInterface.OnClickListener to View.OnClickListener.

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

Sidebar

Related Questions

Hello i need to use writerreaderlock in my method. I want to know how
Hello! I tried to use a delegate in my app. My project uses ARC
hello i use fread like this to get an integer from an url: $f
Hello I need use Cyrillic chars inside of UrlRewriting.config Does any one know how
Hello im trying to use random integer range and the values that i get
Hello i'm trying to use facebook server-side authenticaion to get the access token but
Hello at the moment i'm trying to use jQuery in order to get ids
Hello I am writing an app that makes the use of coordinates from a
Hello I have use DOMDocs in the past but I am stuck how to
Hello I would like to use preg_match in PHP to parse the Desired text

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.