简体   繁体   中英

Android application throwing null on SetContentView

I have a pretty simple application right now. Here is the main Activity class

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);     
    setContentView(R.layout.main);

    connectButton = (ConnectButton) findViewById(R.id.connect);
    connectButton.init(this, facebook, new String [] { "publish_stream",
            "friends_about_me" });

}

And here is part of the R.java class

public static final class layout {
        public static final int main=0x7f030000;
    }

and the main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

  <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/layout1"
        android:orientation="vertical" > 

   <ImageButton android:background="@drawable/facebookconnect" android:id="@+id/connect" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageButton>

   </LinearLayout>
</LinearLayout>

When i click on the application from the AVD, it throws an error and makes me force close the application. It is throwing a null pointer at the SetContentView(R.layout.main).

Any help would be appreciated

Clean your project. In eclipse go to Project --> Clean...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM