1 用imageview控件为他添加长按事件; 2 imageview.setOnLongClickListener(new OnLongClickListener(){ 3 public boolean onLongClick(View v) 4 { 5 try { 6 //MainActivity是当前的activity 7 MainActivity.this.clearWallpaper();//清楚墙纸 8 MainActivity.this.setWallpaper(getResources().openRawResource(R.drawable.b));//设置新的墙纸 9 tost(); 10 } 11 catch (Exception e) { 12 e.printStackTrace(); 13 } 14 return true; 15 } 16 }); 17 2.在mainfest.xml文件中添加注册权限 18 <uses-permission android:name="android.permission.SET_WALLPAPER"/>