2012-03-02 17 views
0

これらのボタンを作成しましたが、(//ボタン)のすべての行で「error:idは解決できないか、フィールドではありません」というエラーが表示され、 layourは解決できないか(r.layou.main)hweverのフィールドは、「エラー:IDは解決できないか、フィールドではありません

私のレイアウトkeypad.xmlすべてのエラーを参照keypad.Java

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


     //Buttons 
     one= (Button) findViewById(R.id.keypad_1); 
     two= (Button) findViewById(R.id.keypad_2); 
     three= (Button) findViewById(R.id.keypad_3); 
     four= (Button) findViewById(R.id.keypad_4); 
     five = (Button) findViewById(R.id.keypad_5); 
     six= (Button) findViewById(R.id.keypad_6); 
     seven = (Button) findViewById(R.id.keypad_7); 
     eight = (Button) findViewById(R.id.keypad_8); 
     nine = (Button) findViewById(R.id.keypad_9); 
     minus = (Button) findViewById(R.id.keypad_subtract); 
     hash = (Button) findViewById(R.id.keypad_hash); 

keypad.xml

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

<TextView 
     android:id="@+id/Title" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="15dp" 
     android:textSize="45sp"> 
</TextView> 

<TableLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/keypad" 
android:orientation="vertical" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:stretchColumns="*" > 

     //setting up keypad buttons one, two and three in one row 
<TableRow> 
<Button android:id="@+id/keypad_1" 
android:text="@string/keypad_1" > 
</Button> 
<Button android:id="@+id/keypad_2" 
android:text="@string/keypad_2" > 
</Button> 
<Button android:id="@+id/keypad_3" 
android:text="@string/keypad_3" > 
</Button> 
</TableRow> 
     //setting up keypad buttons 4,5 and 6 in second row 
<TableRow> 
<Button android:id="@+id/keypad_4" 
android:text="@string/keypad_4" > 
</Button> 
<Button android:id="@+id/keypad_5" 
android:text="@string/keypad_5" > 
</Button> 
<Button android:id="@+id/keypad_6" 
android:text="@string/keypad_6" > 
</Button> 
</TableRow> 

     //setting up keypad buttons 7,8 and 9 in third row 
<TableRow> 
<Button android:id="@+id/keypad_7" 
android:text="@string/keypad_7" > 
</Button> 
<Button android:id="@+id/keypad_8" 
android:text="@string/keypad_8" > 
</Button> 
<Button android:id="@+id/keypad_9" 
android:text="@string/keypad_9" > 
</Button> 
</TableRow> 
     //setting up keypad buttons del,0,# and - in forth row 
<TableRow> 
    <Button android:id="@+id/delete" 
android:text="@string/keypad_DEL" > 
</Button> 
<Button android:id="@+id/keypad_0" 
android:text="@string/keypad_0" > 
</Button> 
<Button android:id="@+id/keypad_hash" 
android:text="@string/keypad_#" > 
</Button> 
<Button android:id="@+id/keypad_subtract" 
android:text="@string/keypad_-" > 
</Button> 
</TableRow> 
</TableLayout> 

    <TextView 
     android:id="@+id/incorrect" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/incorrect" /> 
</LinearLayout> 
いけません
+0

あなたの問題がどこにあるのかを伝えるのは難しいです。いくつか試してみよう:eclipseであなたのプロジェクトを右クリックし、 "clean project"を選択してください。また、R – FoamyGuy

+0

さんに感謝しています...解決済みのものをインポートしていないことを確認してください!なぜ私はオブジェクトRのプライベートフィールドがあったのですか... –

答えて

1

プロジェクトはまだコンパイルされていないようです。プロジェクトを右クリックして、プロジェクトをクリーンアップします。 xmlにコンパイルエラー(赤いマーク)がない場合は、cleanを実行して問題を解決する必要があります。

1

stringとidの名前が同じであるためにこのエラーが発生する可能性はありますか?

0

あなたは、レイアウトのための間違った.xmlファイルを呼び出している:

setContentView(R.layout.main); 

は次のようになります。また、

setContentView(R.layout.keypad); 

、あなたはあなたのonCreateメソッド上記のボタンを作成している、あなたがそれらを結ぶ前に、 ID?

private Button one; 
private Button two; 
// and the rest of them... 
関連する問題