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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:54:18+00:00 2026-06-17T15:54:18+00:00

I am trying to setText of edittext using java but it is not working

  • 0

I am trying to setText of edittext using java but it is not working and force closing my application, though i am not sure why

Java Code

EditText UserProfileFirstName;
UserProfileFirstName = (EditText) findViewById(R.id.userFirstName);
UserProfileFirstName.setText("John");

Xml

<EditText 
   android:id="@+id/userFirstName"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:inputType="text"
   android:textSize="22sp"
   android:layout_marginTop="40dp"
   android:layout_marginBottom="15dp"
   android:hint="First Name"
   android:ems="10"
  />

LogCat Error

        01-23 09:32:15.564: E/AndroidRuntime(4101): FATAL EXCEPTION: main
        01-23 09:32:15.564: E/AndroidRuntime(4101): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.unext.unextlibrary/com.unext.unextlibrary.ProfileActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.unext.unextlibrary/com.unext.unextlibrary.UserProfile}: java.lang.NullPointerException
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.os.Handler.dispatchMessage(Handler.java:99)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.os.Looper.loop(Looper.java:137)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.app.ActivityThread.main(ActivityThread.java:5039)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at java.lang.reflect.Method.invokeNative(Native Method)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at java.lang.reflect.Method.invoke(Method.java:511)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at dalvik.system.NativeStart.main(Native Method)
        01-23 09:32:15.564: E/AndroidRuntime(4101): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.unext.unextlibrary/com.unext.unextlibrary.UserProfile}: java.lang.NullPointerException
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:2023)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:749)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.widget.TabHost.setCurrentTab(TabHost.java:413)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.widget.TabHost.addTab(TabHost.java:240)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at com.unext.unextlibrary.ProfileActivity.onCreate(ProfileActivity.java:105)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.app.Activity.performCreate(Activity.java:5104)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     ... 11 more
        01-23 09:32:15.564: E/AndroidRuntime(4101): Caused by: java.lang.NullPointerException
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at com.unext.unextlibrary.UserProfile.onCreate(UserProfile.java:57)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.app.Activity.performCreate(Activity.java:5104)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
        01-23 09:32:15.564: E/AndroidRuntime(4101):     ... 21 more

I searched on google and also saw SO answers but nothing seems to be working for me

  • 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-17T15:54:19+00:00Added an answer on June 17, 2026 at 3:54 pm

    Add
    setContentView(R.layout.LAYOUTNAME); in oncreate, before you try to get view by

    UserProfileFirstName = (EditText) findViewById(R.id.userFirstName);

    // here LAYOUTNAME is your layout’s name where you define this edittext

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

Sidebar

Related Questions

When I am trying to display a text in EditText using setText() method the
I'm trying to test SharedPreferences by using the code in developer.android.com SharedPreferences . I
I'm trying to use Google Map in Android Application. MainActivity contains EditText, ImageButton and
I've got a problem with populating an edittext. Using the following code i can
I'm trying to pull data from a QR code via zxing using the following
I'm trying to append text lines with this code SendMessage(Form1.log.Handle, WM_SETTEXT, 0, Integer(PChar(textLog))); //
NSString *yValue; yValue= [[NSString alloc] initWithFormat:@%1.2f, imageView.center.y]; [label setText:yValue]; I am trying to display
I am tring to setText in another thread, that is, child thread. But for
Trying to build out an exception if move.UserId does not equal currentUserId then Redirect
Im trying to make an app that converts distance/area/volume using spinners as a unit

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.