luigifonti Posted February 14, 2012 Share Posted February 14, 2012 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: android:id="@+id/widget0" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" > android:id="@+id/vista" android:layout_width="300px" android:layout_height="330px" android:layout_x="9px" android:layout_y="8px" /> Quote Link to comment Share on other sites More sharing options...
FU3L Posted February 14, 2012 Share Posted February 14, 2012 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)); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.