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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:27:17+00:00 2026-05-29T09:27:17+00:00

I am trying to put a button on a View of a Tab on

  • 0

I am trying to put a button on a View of a Tab on Android. Everything compiles and builds well, but app can’t launch. MenuActivity is an activity of a particular tab called Menu of tab widget.

This is my code:

package ru.infolizard.medinfo;

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

public class MenuActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.menu);

        Button button = (Button)this.findViewById(R.id.buttonSearch);
        button.setOnClickListener(new OnClickListener () { 

             public void onClick(View v) { 
                 //Toast.makeText(MenuActivity.this, "Menu pressed", Toast.LENGTH_SHORT).show();
             }  
        });
    }
}

This is LogCat:

    02-03 17:58:41.255: E/AndroidRuntime(1065): FATAL EXCEPTION: main
02-03 17:58:41.255: E/AndroidRuntime(1065): java.lang.RuntimeException: Unable to start activity ComponentInfo{ru.infolizard.medinfo/ru.infolizard.medinfo.MedInfoTabWidgetActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{ru.infolizard.medinfo/ru.infolizard.medinfo.MenuActivity}: java.lang.NullPointerException
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.os.Looper.loop(Looper.java:137)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.app.ActivityThread.main(ActivityThread.java:4424)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at java.lang.reflect.Method.invokeNative(Native Method)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at java.lang.reflect.Method.invoke(Method.java:511)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at dalvik.system.NativeStart.main(Native Method)
02-03 17:58:41.255: E/AndroidRuntime(1065): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{ru.infolizard.medinfo/ru.infolizard.medinfo.MenuActivity}: java.lang.NullPointerException
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:1797)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:682)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.widget.TabHost.setCurrentTab(TabHost.java:346)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.widget.TabHost.addTab(TabHost.java:236)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at ru.infolizard.medinfo.MedInfoTabWidgetActivity.onCreate(MedInfoTabWidgetActivity.java:29)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.app.Activity.performCreate(Activity.java:4465)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
02-03 17:58:41.255: E/AndroidRuntime(1065):     ... 11 more
02-03 17:58:41.255: E/AndroidRuntime(1065): Caused by: java.lang.NullPointerException
02-03 17:58:41.255: E/AndroidRuntime(1065):     at ru.infolizard.medinfo.MenuActivity.onCreate(MenuActivity.java:18)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.app.Activity.performCreate(Activity.java:4465)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-03 17:58:41.255: E/AndroidRuntime(1065):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
02-03 17:58:41.255: E/AndroidRuntime(1065):     ... 21 more

If I comment everything concerning a button, it works fine.

  • 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-29T09:27:18+00:00Added an answer on May 29, 2026 at 9:27 am

    Yours res/layout/menu.xml does not have button with id R.id.buttonSearch (id android:id=”@+id/buttonSearch”)

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

Sidebar

Related Questions

I trying to put together an Android app that will take a picture and
I'm trying to put together a Java Webstart app, but don't want it to
I'm trying to put together an Android view that has several elements stacked on
I am trying to put a JavaFX button in a specific place (specific coordinates)
i am new to android. in my application i have a button .i put
I am trying to put a view in my main silverlight webpage by importing
I'm trying to dynamically put a bitmap in between a Textview and a Button:
I am trying to get the coordinates from a touch but I can't figure
I trying to set visibility of my imageview , button and textview. But they
I'm trying to put a button to footer of TableView. This is what i

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.