I am currently developing a small Android app in Xamarin, using C#.
The following shows up when I run it on my emulator:
This line of code is called when the first tab is selected, which is by default, meaning that this error occurs as soon as I run the program. The XML snippet which seems to be causing the error is this, in one of my layout files:
android:background="@color/done"
This is in line 111 of Dialer.axml, the entirety of which is below. Here, I am trying to reference a color state list for my button, so that the color changes depending on whether it is being touched or not. I know that this line causes the error, because removing it from the button
tag which it's in causes the program to run perfectly. Here is the code for done.xml
, in my color
folder:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:color="#ff2222ff"/>
<item android:state_pressed="true" android:state_enabled="false" android:color="#ff4444ff"/>
<item android:state_enabled="false" android:color="#ff000000"/>
<item android:color="#ff0000ff"/>
</selector>
And here is the code for Dialer.axml
:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tableLayout1"
android:background="#2ec0ff">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="50sp"
android:layout_marginBottom="40sp"
android:id="@+id/number"
android:editable="false"
android:singleLine="true"
android:scrollHorizontally="true"
android:gravity="right"
android:textColor="#fff" />
<TableRow
android:id="@+id/tableRow1"
android:layout_weight="1">
<Button
android:text="1"
android:layout_column="0"
android:id="@+id/button1"
android:layout_weight="1"
android:layout_height="match_parent" />
<Button
android:text="2"
android:layout_column="1"
android:id="@+id/button2"
android:layout_weight="1"
android:layout_height="match_parent" />
<Button
android:text="3"
android:layout_column="2"
android:id="@+id/button3"
android:layout_weight="1"
android:layout_height="match_parent" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_weight="1">
<Button
android:text="4"
android:layout_column="0"
android:id="@+id/button4"
android:layout_weight="1"
android:layout_height="match_parent" />
<Button
android:text="5"
android:layout_column="1"
android:id="@+id/button5"
android:layout_weight="1"
android:layout_height="match_parent" />
<Button
android:text="6"
android:layout_column="2"
android:id="@+id/button6"
android:layout_weight="1"
android:layout_height="match_parent" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_weight="1">
<Button
android:text="7"
android:layout_column="0"
android:id="@+id/button7"
android:layout_weight="1"
android:layout_height="match_parent" />
<Button
android:text="8"
android:layout_column="1"
android:id="@+id/button8"
android:layout_weight="1"
android:layout_height="match_parent" />
<Button
android:text="9"
android:layout_column="2"
android:id="@+id/button9"
android:layout_weight="1"
android:layout_height="match_parent" />
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_weight="1">
<Button
android:text="*"
android:layout_column="0"
android:id="@+id/buttonStar"
android:layout_weight="1"
android:layout_height="match_parent" />
<Button
android:text="0"
android:layout_column="1"
android:id="@+id/button0"
android:layout_weight="1"
android:layout_height="match_parent" />
<Button
android:text="#"
android:layout_column="2"
android:id="@+id/buttonPound"
android:layout_weight="1"
android:layout_height="match_parent" />
</TableRow>
<Button
android:text="Done"
android:id="@+id/buttonDone"
android:background="@color/done"
android:layout_width="match_parent"
android:layout_height="80sp"
android:textSize="35sp"
android:layout_margin="5sp" />
</TableLayout>
What is causing the error? Am I referencing done.xml
incorrectly? Did I place it in the wrong folder?
Thanks in advance.