请原谅我是新手,我的术语可能不正确:
I have an array of images in class1, when an image is selected its id is passed to class2 (code below) I then display that image and give the option to set it as a wallpaper. 问题是,使用下面的代码我需要一个drawable来分配壁纸,而不是ImageView。有人可以给我一些指导来参考我有“myWallpaperManager.setResource(这里需要一个drawable);”的实际drawable
提前致谢。希望这是有道理的,正如我所说的我是一个菜鸟!
public class FullWallView extends Activity {
private Button wallbutton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wallpaper_full);
// get intent data
Intent i = getIntent();
// Selected image id
int position = i.getExtras().getInt("id");
ImageAdapter imageAdapter = new ImageAdapter(this);
ImageView imageView = (ImageView) findViewById(R.id.full_wall_view);
imageView.setImageResource(imageAdapter.mThumbIds[position]);
//Making Button Clickable and setting the wallpaper
wallbutton = (Button) findViewById(R.id.apply);
wallbutton.setOnClickListener(new Button.OnClickListener()
{
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
WallpaperManager myWallpaperManager
= WallpaperManager.getInstance(getApplicationContext());
try {
myWallpaperManager.setResource(need a drawable here);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}});