これが単純なものであることを願っています。
私はここで解決できないように見える非常に単純な問題を抱えています。findViewByIdなどを使用してXMLレイアウトのEditTextをコードに参照しようとしています。何らかの理由で、プロジェクトをクリーンアップしてRリソースファイルを再生成し、ctrl+oを使用してインポートを確認しました。 EclipseにXMLレイアウトのEditTextへのリンクを「表示」させることができません。
うまくいけば、誰かがこのイライラする単純なエラーで私を助けてくれるでしょう。
現在、エラーは次のとおりです。
totalListPrice cannot be resolved or is not a field
これは、'totalListPriceを参照するために使用される単純なコードです。私のXMLから私のコードのEditTextへ:
totalPrice = (EditText)findViewById(android.R.id.totalListPrice);
そしてこれは私のXMLレイアウトです(問題のあるEditTextがマークされています):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="84dp"
android:orientation="horizontal"
android:focusableInTouchMode="false">
<ImageView
android:id="@+id/imgLink"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/viewcon" />
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="75dp"
android:gravity="center"
android:text="Shopping List"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="35sp"
android:focusableInTouchMode="false"
android:clickable="false"
android:focusable="false" />
</LinearLayout>
<TextView
android:id="@+id/txtItemDes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="Search From An Item In The List:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/inputAppointName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Enter An Item Name" >
<requestFocus />
</EditText>
<Button
android:id="@+id/btnAddItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add"/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="56px"
android:orientation="horizontal" >
<TextView
android:id="@+id/txtPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total Price:"
android:textAppearance="?android:attr/textAppearanceMedium" />
*************ERROR*************
<EditText
android:id="@+id/totalListPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number"></EditText>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>