複数の画像があり、使用するWallpaperManager
と、壁紙を設定すると言われているものに壁紙が設定されます。どうすれば toPhone と WallpaperManager を使用できますか?
Java ファイル (必要な場合):
package hd.wallpaper.abs;
import java.io.IOException;
import android.app.Activity;
import android.app.WallpaperManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class Main extends Activity implements View.OnClickListener {
ImageView display;
int toPhone;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hd__wallpapers);
toPhone = R.drawable.eye;
display = (ImageView) findViewById(R.id.IVdisplay);
ImageView image1 = (ImageView) findViewById(R.id.IVimage1);
ImageView image2 = (ImageView) findViewById(R.id.IVimage2);
ImageView image3 = (ImageView) findViewById(R.id.IVimage3);
ImageView image4 = (ImageView) findViewById(R.id.IVimage4);
ImageView image5 = (ImageView) findViewById(R.id.IVimage5);
ImageView image6 = (ImageView) findViewById(R.id.IVimage7);
Button setWall = (Button) findViewById(R.id.setwallpaperbutton);
image1.setOnClickListener(this);
image2.setOnClickListener(this);
image3.setOnClickListener(this);
image4.setOnClickListener(this);
image5.setOnClickListener(this);
image6.setOnClickListener(this);
setWall.setOnClickListener(this);
}
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.IVimage1:
display.setImageResource(R.drawable.i1);
toPhone = R.drawable.i1;
break;
case R.id.IVimage2:
display.setImageResource(R.drawable.i2);
toPhone = R.drawable.i2;
break;
case R.id.IVimage3:
display.setImageResource(R.drawable.i3);
toPhone =R.drawable.i3;
break;
case R.id.IVimage4:
display.setImageResource(R.drawable.i3);
toPhone =R.drawable.i3;
break;
case R.id.IVimage5:
display.setImageResource(R.drawable.i3);
toPhone =R.drawable.i3;
break;
case R.id.IVimage7:
display.setImageResource(R.drawable.i3);
toPhone =R.drawable.solar;
break;
case R.id.setwallpaperbutton:
final WallpaperManager myWallpaperManager
= WallpaperManager.getInstance(getApplicationContext());
final int fullWidth = myWallpaperManager.getDesiredMinimumWidth();
final int fullHeight = myWallpaperManager.getDesiredMinimumHeight();
try {
myWallpaperManager.setResource(R.drawable.i1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
break;
}
}
}