LINUX.ORG.RU

backgroundcolor

 


0

1

color.java

package com.example.a_try_1;


import android.os.Bundle;

import android.app.Activity;

import android.view.View;
import android.view.View.OnClickListener;

import android.widget.Button;

public class Color extends Activity {
View r1;
Button b1;
@Override

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

r1 = (View)findViewById(R.id.xyu);
setContentView(R.layout.color);
addListenerOnButton();

}
private void addListenerOnButton() {
b1 = (Button) findViewById(R.id.button1);

b1.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
r1.setBackgroundColor(0xFF00FF00);
}
});


}}
color.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android";
xmlns:tools="http://schemas.android.com/tools";
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/xyu"
>

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Button" />
R.java
</RelativeLayout>
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/

package com.example.a_try_1;

public final class R {
public static final class attr {
}
public static final class color {
public static final int greenColor=0x7f060000;
}
public static final class drawable {
public static final int ic_action_search=0x7f020000;
public static final int ic_launcher=0x7f020001;
}
public static final class id {
public static final int button1=0x7f090000;
public static final int button2=0x7f090001;
public static final int button3=0x7f090002;
public static final int menu_settings=0x7f090005;
public static final int toggleButton1=0x7f090004;
public static final int xyu=0x7f090003;
}
public static final class layout {
public static final int activity_main=0x7f030000;
public static final int color=0x7f030001;
public static final int sound=0x7f030002;
public static final int vibrator=0x7f030003;
}
public static final class menu {
public static final int activity_main=0x7f080000;
}
public static final class raw {
public static final int explosion=0x7f040000;
}
public static final class string {
public static final int app_name=0x7f050000;
public static final int hello_world=0x7f050001;
public static final int menu_settings=0x7f050002;
public static final int title_activity_main=0x7f050003;
}
public static final class style {
public static final int AppTheme=0x7f070000;
}
}
Почему не могу через код изменить backgroundcolor?


Ответ на: комментарий от Vinick

Спасибо, добрый человек, мы вроде так пробовали, но не работало почему-то.

Ltm
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.