Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
LinkBack Thread Tools
Old September 28th, 2010, 06:53 AM   #1 (permalink)
New Member
Thread Author (OP)
Join Date: Sep 2010
Posts: 1
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Nullpointer when updating simple TextView

Hi, I am writing my first android GUI, it consists of a TabLayout with 3 tabs. In one of these I want to update the view from a back-end thread that fires events containing a number that I want to write to the screen. Everything works fine until I actually get the call on the updateView method sent to the UI from my observer, then the App crashes from a nullpointer in my getViewById() call :S

This is the activity for the tab that I want to update the view in. It initiates fine and sets the textview to display the initial value of 0, but when the event arrives it crashes and I get a nullpointer at the comment.

I can get my TabActivity to update its view, but I cant get the separate Activity to update its own tab.

Any thoughts?

public class Realtime extends Activity{
    private BigInteger data = BigInteger.valueOf(0);
    private Handler handler = new Handler();
    private Runnable updateTask = new Runnable(){

        public void run() {
            handler.postDelayed(this, 1000);

    public void onCreate(Bundle savedInstanceState) {
        handler.postDelayed(updateTask, 1000);    
    private void updateData(){
        final TextView textview = (TextView)findViewById(R.id.blips); //This is where I get my nullpointer
    public void updateView(BigInteger data){
        this.data = data;
        handler.postDelayed(updateTask, 1000);
    protected void onStop() {
    protected void onResume() {
        handler.postDelayed(updateTask, 1000);
    protected void onDestroy() {
        if ( handler != null )
        handler = null;        

hirden is offline  
Last edited by hirden; September 28th, 2010 at 10:04 AM. Reason: More info
Reply With Quote
sponsored links

Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

All times are GMT -5. The time now is 12:32 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.