Null Pointer Exception on accessing value of EditText

by Ankur Kumar » Fri, 20 May 2011 09:30:39 GMT


Sponsored Links
 Hello Developers,

Please help me with this problem. I am getting
java.lang.NullPointerException at step 3 in my code. Have not been
able to figure this out. The value I am entering in the EditText is
not empty.

                       1.  EditText IPInput = (EditText)
findViewById(R.id.ip);
                       2.  IPInput.getText().toString(); System.out.println(ip);
                       3.  System.out.println(IPInput.getText().toString());

--
Regards,
Ankur Kumar

-- 



Null Pointer Exception on accessing value of EditText

by Ankur Kumar » Fri, 20 May 2011 09:30:40 GMT


 Hello Developers,

Please help me with this problem. I am getting*java.lang.NullPointerException
* at step 3 in my code. Have not been able to figure this out. The value I
am entering in the EditText is not empty.

                       1.  EditText IPInput = (EditText)
findViewById(R.id.ip);
       2.  IPInput.getText().toString(); System.out.println(ip);
        3.  System.out.println(IPInput.getText().toString());



--
Regards,
Ankur Kumar

-- 


Sponsored Links


Other Threads

1. [BUG] Easily Reproducable Bug in Regards to Bitmaps, Memory, and Recycling [sample project included]

In a nutshell, I have/am trying to create reusable UI components in
XML.  I created a dead simple project that only fires an activity to
show the UI.  It can be downloaded here:

http://dl.dropbox.com/u/409429/Bitmap%20Bg%20Test.zip

I have a "base_form.xml" component that is referenced
(setContentView()) in "BaseForm.java", a base Activity.  The
base_form.xml is a FrameLayout where the background is set to a
drawable (a 16 kb png).

I now have "LoginForm.java" that extends BaseForm and a subsequent
"login_form.xml" component.  This login_form component is inflated in
LoginForm.java and "appended" to the view and remember, the view was
set in BaseForm.java via setContentView(R.layout.base_form).

It should be noted that in the BaseForm.java there is a method called
"cleanupDrawables()" which recycles the bitmap being used in the
FrameLayout and sets various things to null.  It even explicitly calls
System.gc() (I've tried it without and still the same issue).

Upon firing the app, everything works fine.  UI loads up and displays
properly.

Now, hit the back button.

Now, open the app again.  Everything is fine.

Hit the back button again.

Now open the app again.  Breaks with this exception:

FATAL EXCEPTION: main
E/AndroidRuntime(  405): java.lang.RuntimeException: Canvas: trying to
use a recycled bitmap android.graphics.bit...@44f4c150


So after discussing this issue with some other engineers it appears it
is a bug in the garbage collector that is occurring after the 2nd
sweep.  Apparently a very similar bug existed in early .Net.

A solution may be to instead of defining the background in XML to load
a bitmap using BitmapFactory and explicitly set the background of the
FrameLayout in Java.  This is undesirable as it doesn't really allow
me to create reusable UI components in XML.

Any help is greatly appreciated.


Also, it appears this is a bug that is "declined" by the Android
team.  "Use less memory in your app" was the original solution
suggested by Romain Guy.

http://code.google.com/p/android/issues/detail?id=8488

-- 

2. Eclipse ADT update ruins XML layout files development

I recently updated my eclipse installation with which I develop my
Android apps.
Soon I found my layout files have lost the up and down arrows
associated with each VIEW and LAYOUT which helps to organize my
layouts.

I don't know whatelse the update, if anything, has messed up but I
wonder and would appreciate any information on how to fix this issue
so I can get my developments back on track, please.

Thanks

-- 

3. HTTPS POST problem

4. Running adb logcat and dmesg commands from within my app.

5. samsung kernel tree can't compile for non-s5p chips

6. Issue with USB device current consumption in Self Powered mode

7. playing RTSP over HTTP tunnel (RTP/TCP/AVP)