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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:54:12+00:00 2026-06-08T22:54:12+00:00

I have the following function that is called after a menu item is clicked.

  • 0

I have the following function that is called after a menu item is clicked. Basically I have some string which I try to set to a TextView located inside an AlertDialog.

public void createAboutDialog() {
    View layout = mContext.getSystemService(LAYOUT_INFLATER_SERVICE).inflate(R.layout.about, null);

    TextView tv = (TextView) findViewById(R.id.myTextView);
    tv.setText("My text here");

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setView(layout);

    AlertDialog alertDialog = builder.create();
    alertDialog.show();
}

The issue appears to be related to the setText() call.

LogCat

08-01 14:19:33.423: D/MainActivity(1793): 1.0
08-01 14:19:33.473: D/AndroidRuntime(1793): Shutting down VM
08-01 14:19:33.473: W/dalvikvm(1793): threadid=1: thread exiting with uncaught exception (group=0x2b542210)
08-01 14:19:33.603: E/AndroidRuntime(1793): FATAL EXCEPTION: main
08-01 14:19:33.603: E/AndroidRuntime(1793): java.lang.NullPointerException
08-01 14:19:33.603: E/AndroidRuntime(1793):     at com.example.your.chinese.name.MainActivity.createAboutDialog(MainActivity.java:105)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at com.example.your.chinese.name.MainActivity.onOptionsItemSelected(MainActivity.java:74)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.app.Activity.onMenuItemSelected(Activity.java:2502)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:969)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at com.android.internal.view.menu.ListMenuPresenter.onItemClick(ListMenuPresenter.java:163)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.widget.AdapterView.performItemClick(AdapterView.java:292)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.widget.AbsListView.performItemClick(AbsListView.java:1065)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.widget.AbsListView$PerformClick.run(AbsListView.java:2522)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.widget.AbsListView.onTouchEvent(AbsListView.java:3195)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.view.View.dispatchTouchEvent(View.java:5564)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2052)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1813)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2058)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1827)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1879)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.view.View.dispatchPointerEvent(View.java:5766)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2890)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2466)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:845)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2475)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.os.Looper.loop(Looper.java:137)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at android.app.ActivityThread.main(ActivityThread.java:4441)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at java.lang.reflect.Method.invokeNative(Native Method)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at java.lang.reflect.Method.invoke(Method.java:511)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-01 14:19:33.603: E/AndroidRuntime(1793):     at dalvik.system.NativeStart.main(Native Method)
08-01 14:19:35.583: I/Process(1793): Sending signal. PID: 1793 SIG: 9
  • 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-08T22:54:14+00:00Added an answer on June 8, 2026 at 10:54 pm

    You need to call findViewById() from the correct context:

    TextView tvVersion = (TextView) layout.findViewById(R.id.tvAboutdialogVersion);
    

    If not provided, it will be called from the Activity context, which has loaded the main XML view and it doesn’t have access/reference to the dialog’s XML (and its TextViews) which you just inflated.

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

Sidebar

Related Questions

I have the following function that does string splitting: on splitText(aString, delimiter) set retVal
I have the following function that is meant to get called after a form
I have an MS SQL function that is called with the following syntax: SELECT
I have a subprocess function (called parseContents) that gets called using the following code:
I have a function, 'redirect_to()' written on php script that is called after a
I have the following function that works properly in Chrome and Firefox, but not
I have the following function that deletes the LaTeX command surrounding the current cursor
I have the following function that I am using to remove the characters \04
I have the following function that takes a number like 5 and creates a
I have the following function that retrieves an image from a twitter feed, the

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.