help on Android

by Billsen » Fri, 27 Jun 2008 07:48:50 GMT


Sponsored Links
 Hi,

I am a new comer to Android and need a help. Here is my question? How
to get to a new activity by clicking a button.
What is what I did.

In class CompantMenu, I have code like this

.........
.........
 listButton.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                        listCompany();

                }
            });

.........
.........
public void listCompany(){
                Intent i = new Intent(this,ListCompany.class);
                startActivity(i);
        }

In class ListCompany, I have code like this,

 public void onCreate(Bundle icicle) {
                 super.onCreate(icicle);
                setContentView(R.layout.list_company);
         }

Node:list_company.xml is availabe and classes ListCompany CompantMenu
are in AndroidManifest.xml.

When I lick listButton, I did not get page defined by list_company,
instead, I got java.long.NullPointerException.

How solve this issue?

Thanks

Billsen

--~--~---------~--~----~------------~-------~--~----~



help on Android

by Mark Murphy » Fri, 27 Jun 2008 08:20:38 GMT


 


You should probably look at the stack trace (e.g., via adb logcat) to 
see where exactly you got the exception. That may help you determine if 
the problem is with CompantMenu or with ListCompany and may give you a 
clue as to what pointer is null.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
Warescription: All titles, revisions, & ebook formats, just $35/year

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


help on Android

by Juven Xu » Fri, 27 Jun 2008 11:56:11 GMT


 please paste the stack trace to help figure out the root cause



--~--~---------~--~----~------------~-------~--~----~