2013-04-29 93 views
1

上幾個按鈕,我有以下代碼顯示java.lang.NullPointerException菜單欄

imgAbout = (ImageView) findViewById(R.id.imgAbout); 
    imgAbout.setOnClickListener(new ButtonListner(RecipesList.this)); 

    imgFeedback = (ImageView) findViewById(R.id.imgFeedback); 
    imgFeedback.setOnClickListener(new ButtonListner(RecipesList.this)); 

    imgSearchNav = (ImageView) findViewById(R.id.imgSearchNav); 
    btnSearch = (Button) findViewById(R.id.btnSearch); 
    edtSearch = (EditText) findViewById(R.id.edtSearch); 

,其中線4 giging我NullPointerException異常錯誤是什麼我能找到。

這是從XML佈局

<RelativeLayout 
    android:id="@+id/lytTitleBar" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:background="@drawable/titlebar"> 
    <TextView 
     android:id="@+id/txtTitleApp" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/app_name" 
     android:textSize="16sp" 
     android:textStyle="bold" 
     android:textColor="@color/title_app" 
     android:layout_centerVertical="true" 
     android:layout_alignParentLeft="true"/> 
    <ImageView 
     android:id="@+id/imgAbout" 
     android:layout_width="24dp" 
     android:layout_height="24dp" 
     android:src="@drawable/about" 
     android:layout_centerVertical="true" 
     android:layout_alignParentRight="true"/> 

    <ImageView 
     android:id="@+id/imgFeedback" 
     android:layout_width="24dp" 
     android:layout_height="24dp" 
     android:layout_alignRight="@+id/txtTitleApp" 
     android:layout_marginRight="34dp" 
     android:layout_centerVertical="true" 
     android:src="@drawable/feedback" /> 
</RelativeLayout> 

這是不會發生的每一個人。我只有9在我的開發者控制檯崩潰報告出來500+有效安裝

+0

這是第4行?並且在XML – JRowan 2013-04-29 01:16:47

+0

imgFeedback.setOnClickListener(新ButtonListner(RecipesList.this))沒有按鈕; – Sam 2013-04-29 04:45:07

+0

我應該在xml上添加一個按鈕嗎? – Sam 2013-04-29 04:45:31

回答

0

確定。弄清楚了。 這個問題只發生在高分辨率的平板電腦上。 問題奠定的事實,有在佈局/大文件夾這些按鈕沒有XML refrence。