안녕하세요
만든 의도는 기본적으로 default 배경색을 가진 상태에서,
추후 사용자가 배경색 선택을 할 수 있는 기능을 넣어보려는데요.
어플실행시 지정한 Background color가 전혀 먹히지 않습니다.
이상한 건 화면의 우측의 Design(미리보기?) 화면에서는 default 색상이 잘 보입니다.
배경색 변경버튼은 이상없이 잘 작동되구요..
어떻게 처리를 해야할지 이것저것 시도를 많이 해봤는데 전부 동일한 결과네요..
<activity_main.XML>
<RelativeLayout
android:background="@color/gray"
android:id="@+id/bg_color"
android:layout_width="match_parent"
android:layout_height="595dp"
>
<MainActivity.java>
RelativeLayout bg = (RelativeLayout)findViewById(R.id.bg_color);
int bg_color = getIntent().getIntExtra("bg_color", 0);
bg.setBackgroundResource(bg_color)
<SubActivity.java>
public void onClick(View v) {
switch (v.getId()) {
case R.id.img1:
Intent colorIntent = new Intent(SubActivity.this,MainActivity.class);
colorIntent.putExtra("bg_color",R.color.gray);
startActivity(colorIntent);
break;
case R.id.img2:
colorIntent = new Intent(SubActivity.this,MainActivity.class);
colorIntent.putExtra("bg_color",R.color.yellow);
startActivity(colorIntent);
break;