Jump to content
Android Forum - A Community For Android Users and Enthusiasts

Simple application crashes


luigifonti
 Share

Recommended Posts

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"

/>

Link to comment
Share on other sites

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));

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...