以下は私のxmlファイルのコードです
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/editview_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:filterTouchesWhenObscured="true"
android:orientation="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/userid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="USER ID"
android:textSize="8pt" />
<EditText
android:id="@+id/edituserid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@android:drawable/editbox_background"
android:scrollHorizontally="true"
android:textColor="#333399" />
<TextView
android:id="@+id/usertype"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="USER TYPE"
android:textSize="8pt" />
<Spinner
android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:entries="@array/spinner" />
<TextView
android:id="@+id/company"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="COMPANY"
android:textSize="8pt" />
<EditText
android:id="@+id/editcompany"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:textColor="#333399" />
<TextView
android:id="@+id/firstname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FIRST NAME"
android:textSize="8pt" />
<EditText
android:id="@+id/editfirstname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:textColor="#333399" />
<TextView
android:id="@+id/lastname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LAST NAME"
android:textSize="8pt" />
<EditText
android:id="@+id/editlastname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:textColor="#333399"
/>
<TextView
android:id="@+id/encryptionkey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ENCRYPTION KEY"
android:textSize="8pt" />
<EditText
android:id="@+id/editencryption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background" >
<TextView
android:id="@+id/lasttagupdate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="LAST TAG UPDATE"
android:textSize="8pt" />
<DatePicker
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="10dip"
android:layout_weight="1"
android:endYear="2100"
android:startYear="1900" />
<Button
android:id="@+id/ok"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:text="SAVE" />
</EditText>
</LinearLayout>
</ScrollView>
このレイアウトを使用するファイル
public class writeRFIDTag extends Activity {
EditText userId, company, firstName, lastName, encryptionKey;
Button save;
Spinner spin;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.rfid_write);
userId = (EditText) findViewById(R.id.edituserid);
company = (EditText) findViewById(R.id.editcompany);
firstName = (EditText) findViewById(R.id.editfirstname);
lastName = (EditText) findViewById(R.id.editlastname);
}
}
と私のlogcat
08-21 17:14:51.410: E/AndroidRuntime(20353): FATAL EXCEPTION: main
08-21 17:14:51.410: E/AndroidRuntime(20353): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.securityapp/com.example.securityapp.writeRFIDTag}: java.lang.ClassCastException: android.widget.EditText cannot be cast to android.view.ViewGroup
08-21 17:14:51.410: E/AndroidRuntime(20353): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
08-21 17:14:51.410: E/AndroidRuntime(20353): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
08-21 17:14:51.410: E/AndroidRuntime(20353): at android.app.ActivityThread.access$600(ActivityThread.java:123)
08-21 17:14:51.410: E/AndroidRuntime(20353): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
08-21 17:14:51.410: E/AndroidRuntime(20353): at android.os.Handler.dispatchMessage(Handler.java:99)
08-21 17:14:51.410: E/AndroidRuntime(20353): at android.os.Looper.loop(Looper.java:137)
08-21 17:14:51.410: E/AndroidRuntime(20353): at android.app.ActivityThread.main(ActivityThread.java:4424)