Reputation: 1950
I'm setting a background color in main.xml.
When I preview the layout in Eclipse, the background color shows up correctly, but when the app runs on my device, the background color is default black. It seems none of my changes in main.xml are reflected when the app runs.
Here is my main.xml file
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lst"
android:layout_width="match_parent"
android:background="@color/listViewBG"
android:divider="@drawable/divider"
/>
Here is the OnCreate in the main activity
public class AleWorldActivity extends ListActivity
{
String classes[] = { "Movies", "Pictures" };
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(AleWorldActivity.this, android.R.layout.simple_list_item_1, classes));
}
Any ideas? Thanks
Here is my strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, AleWorldActivity!</string>
<string name="app_name">Ale World</string>
<color name="listViewBG">#e101f5</color>
</resources>
Kevin
Upvotes: 0
Views: 993
Reputation: 14237
You should declare your color on colors.xml
. Create that file in the same folder that strings.xml
is.
Besides that you have some errors:
setContentView(R.layout.main)
on your
AleWorldActivity.android:id="@android:id/list
android:layout_height="wrap_content"
in your ListView xml.Upvotes: 1
Reputation: 18120
Change @color/listViewBG
to #FFFFFF
see if the screen changes colors that means that there is a problem with you declaring it in your strings.xml.
http://developer.android.com/resources/samples/SoftKeyboard/res/values/colors.html
Upvotes: 0