[android]代码库
protected static InputStream is;
Resources resources = getBaseContext().getResources();
is = resources.openRawResource ( mImageAdapter01.myImageIds[position] ); // 可换成任意图片资源
try{
/* 更换桌面背景 */
setWallpaper ( is );
/* 用Toast来显示桌布已更换 */
Toast.makeText (
Test.this,
getString ( R.string.my_gallery_text_pre ),
Toast.LENGTH_SHORT ).show();
}
catch ( Exception e ){
e.printStackTrace();
}
@Override
public void setWallpaper ( InputStream data ) throws IOException{
// TODO Auto-generated method stub
super.setWallpaper ( data );
}