Why, in this very simple example, the last statement (setBackgroundColor)
produces a crash of the application ?
public class Macumba extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView vista = (ImageView)findViewById(R.id.vista);
vista.setBackgroundColor(Color.YELLOW);
}
}
main.xml is very simple, too:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ImageView
android:id="@+id/vista"
android:layout_width="300px"
android:layout_height="330px"
android:layout_x="9px"
android:layout_y="8px"
/>
</AbsoluteLayout>
Simple application crashes
Started by luigifonti, Feb 14 2012 01:17 AM
1 reply to this topic
#1
Posted 14 February 2012 - 01:17 AM
#2
Posted 14 February 2012 - 08:30 AM
luigifonti, on 14 February 2012 - 01:17 AM, said:
vista.setBackgroundColor(Color.YELLOW);
I'm not very experienced in Android app development, but I believe setBackgroundColor expects an int value.
Otherwise,
If you want to use "Color.YELLOW" You may have to write it as
vista.setBackgroundColor(Color.rgb(0x255, 0x255, 0x00));

(OG DROID | Incredible | Charge | CDMA Galaxy Nexus | Xoom | Kindle Fire | Iconia A100 | Sony Google TV | MotoACTV)
Author @ TalkAndroid | Follow @TalkAndroid | Like Us on Facebook | Add Us on G+ | Watch Us on YouTube | Follow Me @FU3L93














