[Java for Android App Development] TwilightLoz:
Ok so im just practising my android skills. What I did was basically make an app that lets the user choose what image to set as the wallpaper or the background of the app.

Ive set the wallpaper up but couldnt find a way to setting the background up for the app/activity.

XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ImageView
android:id="@+id/IVDisplay"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_gravity="center"
android:src="@drawable/bentley" />

<HorizontalScrollView
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="100dp" >

<LinearLayout
android:id="@+id/linearlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<ImageView
android:id="@+id/img1"
android:layout_width="100dp"
android:layout_height="100dp"
android:padding="10dp"
android:src="@drawable/bentley" />

<ImageView
android:id="@+id/img2"
android:layout_width="100dp"
android:layout_height="100dp"
android:padding="10dp"
android:src="@drawable/bugatti" />

<ImageView
android:id="@+id/img3"
android:layout_width="100dp"
android:layout_height="100dp"
android:padding="10dp"
android:src="@drawable/dodge" />

<ImageView
android:id="@+id/img4"
android:layout_width="100dp"
android:layout_height="100dp"
android:padding="10dp"
android:src="@drawable/ic_launcher" />

<ImageView
android:id="@+id/img5"
android:layout_width="100dp"
android:layout_height="100dp"
android:padding="10dp"
android:src="@drawable/rollsroyce" />
</LinearLayout>
</HorizontalScrollView>

<Button
android:id="@+id/wallpaperbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Set as wallpaper" />

<Button
android:id="@+id/bkgbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Set as Background" />

</LinearLayout>

Java:

package com.examples.hello;

import java.io.IOException;
import java.io.InputStream;

import android.app.Activity;
import android.app.WallpaperManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class PAGEONE extends Activity implements OnClickListener {

ImageView display;
int tophone;

[MENTION=439709]override[/MENTION]
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.bkgd);

display = (ImageView) findViewById(R.id.IVDisplay);
tophone = R.drawable.bentley;

Button wallpap = (Button) findViewById(R.id.wallpaperbutton);
Button bkg = (Button) findViewById(R.id.bkgbutton);
ImageView img1 = (ImageView) findViewById(R.id.img1);
ImageView img2 = (ImageView) findViewById(R.id.img2);
ImageView img3 = (ImageView) findViewById(R.id.img3);
ImageView img4 = (ImageView) findViewById(R.id.img4);
ImageView img5 = (ImageView) findViewById(R.id.img5);

img1.setOnClickListener(this);
img2.setOnClickListener(this);
img3.setOnClickListener(this);
img4.setOnClickListener(this);
img5.setOnClickListener(this);
wallpap.setOnClickListener(this);
}

[MENTION=439709]override[/MENTION]
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.img1:
display.setImageResource(R.drawable.bentley);
tophone = R.drawable.bentley;
break;
case R.id.img2:
display.setImageResource(R.drawable.bugatti);
tophone = R.drawable.bugatti;
break;

case R.id.img3:
display.setImageResource(R.drawable.dodge);
tophone = R.drawable.dodge;
break;

case R.id.img4:
display.setImageResource(R.drawable.ic_launcher);
tophone = R.drawable.ic_launcher;
break;

case R.id.img5:
display.setImageResource(R.drawable.rollsroyce);
tophone = R.drawable.rollsroyce;
break;
case R.id.wallpaperbutton:
InputStream yea = getResources().openRawResource(tophone);
Bitmap hmm = BitmapFactory.decodeStream(yea);
WallpaperManager mywallpaper = WallpaperManager.getInstance(getApplicationContext ());
try{
mywallpaper.setResource(tophone);
}catch(IOException e){
e.printStackTrace();
}

}
}

}

I dont know what methods to use. I was thinking of setting up individual pictures as the layouts (so I'd have 5 extra layouts since I have 5 pictures), but that wouldn't make any sense.