2011-07-25 6 views
0

私は頭がおかしくない非常に奇妙な不具合を抱えています。 Android 2.3、タブレット3.1、Android 2.1搭載の携帯電話では動作しませんAndroid findViewById時には

"overview_linear_layout"というIDの次のXMLで定義されているLinearLayoutを取得しようとしています。次のように

<?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"> 
    <include layout="@layout/listing_view" android:layout_width="fill_parent" android:id="@+id/header_view" android:layout_height="wrap_content"></include> 
    <ScrollView android:id="@+id/scrollView1" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content"> 
     <LinearLayout android:layout_width="fill_parent" android:orientation="vertical" android:layout_height="fill_parent" android:id="@+id/overview_linear_layout"> 
      <TextView android:scrollbars="vertical" android:longClickable="false" android:layout_weight="1" android:clickable="false" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/main_description"></TextView> 
     </LinearLayout> 
    </ScrollView> 
    <include layout="@layout/listing_view" android:layout_width="fill_parent" android:id="@+id/footer_view" android:layout_height="wrap_content" android:layout_weight="0.0"></include> 

</LinearLayout> 

overview_view.xmlは、私はビューを取得するために使用していたコードは次のとおりです。

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.overview_view); 
    LinearLayout linearLayout = (LinearLayout)findViewById(R.id.overview_linear_layout); 

    if(linearLayout!=null) { 
     System.out.println("Found linear layout"); 
    } 
    else { 
     System.out.println("Did not find linear layout"); 
    } 
} 

私はプロジェクト - を試してみました>クリーンEclipseでそれは解決しませんどちらか。

+0

あなたのインポートステートメントを投稿してください。 –

答えて

0

変更この

LinearLayout linearLayout = (LinearLayout)findViewById(R.id.overview_linear_layout); 

LinearLayout linearLayout = (LinearLayout)findViewById(R.layout.overview_linear_layout);` 
0

にあなたは赤い十字をクリックして入力し、Rの定数overview_linear_layoutの作成]をクリックしたときに日食がoverview_linear_layout表示されていない場合。

関連する問題