2013-01-23 3 views
2

내 안드로이드 응용 프로그램에는 테마 옵션이 있습니다. 어디에 4 개의 이미지를 사용할 수 있습니다. 이미지 중 하나를 선택한 후에는이를 전체 응용 프로그램의 배경으로 사용하고 싶습니다. 하지만 어떻게 해야할지 잘 모르겠다. 나는 무언가를 시도했지만이 절차가 완벽하지 않을 수 있습니다. 내가 선택한 이미지를 sharedPreference 안에 저장하고 모든 활동 내에서 이미지를 배경으로 설정했습니다. 그러나 때로는 어떤 활동의 배경이 바뀌지 않고 때로는 큰 이미지에 대해 메모리 오류가 발생합니다. 내가 따라야 할 가장 좋은 절차는 무엇입니까? 내가하고 싶은 샘플 이미지 ...내 안드로이드 응용 프로그램을위한 사용자 정의 동적 배경 (테마) 만들기?

enter image description here

+0

@ TKumar : 이것에 대한 해결책을 얻었습니까? – Deepthi

답변

0

확인 이미지 OnClickListener를위한 샘플 코드 ... !!!!!

자바 클래스 -

public OnClickListener onclickimage = new OnClickListener() { 

@Override 
public void onClick(View v) { 

    switch (v.getId()) { 

    case R.id.imageView1: 
     rlayout.setBackgroundResource(R.drawable.bg); 
     break; 
    case R.id.imageView2: 
     rlayout.setBackgroundResource(R.drawable.bg_evening); 
     break; 
    case R.id.imageView3: 
     rlayout.setBackgroundResource(R.drawable.bg_morning); 
     break; 
    case R.id.imageView4: 
     rlayout.setBackgroundResource(R.drawable.bg_night); 
     break; 

    } 

} 
}; 

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
// Inflate the menu; this adds items to the action bar if it is present. 
getMenuInflater().inflate(R.menu.activity_main, menu); 
return true; 
} 

} 

및 레이아웃 코드 : -

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/rlayout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivity" > 

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:src="@drawable/ic_launcher" /> 

<ImageView 
    android:id="@+id/imageView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_toRightOf="@+id/imageView1" 
    android:src="@drawable/ic_launcher" /> 

<ImageView 
    android:id="@+id/imageView3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_toRightOf="@+id/imageView2" 
    android:src="@drawable/ic_launcher" /> 

<ImageView 
    android:id="@+id/imageView4" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_toRightOf="@+id/imageView3" 
    android:src="@drawable/ic_launcher" /> 

</RelativeLayout> 

이 대답은 당신을 도울 수있다 ..... !!!!!!

당신은 ur 루프 이미지를 위해 같은 작업을 수행 할 수 있습니다 ... !!!!!

또는 다음과 같은 테마를 사용할 수 있습니다. !!!!

만약 내가 다른 요구 사항을 완료하지 못한다면 Sry ... !!!

+0

답변 해 주셔서 감사합니다. 이 프로세스는 rlayout.xml의 배경을 변경할 수 있습니다. 하지만 전체 응용 프로그램 배경을 변경하고 싶습니다. 즉, 내 응용 프로그램의 모든 xml, 내가 사용한 80 xml 이상을 의미합니다. – TKumar

+0

Sry하지만 80 xml U의 전체 배경을 바꾸려면 코드만으로 할 수 있습니다 ... !!!!! –

관련 문제