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"/>

 

相关文章:

  • 2022-12-23
  • 2021-12-23
  • 2021-11-29
  • 2022-01-20
  • 2022-12-23
  • 2022-01-02
  • 2021-12-23
  • 2021-07-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-09
  • 2022-12-23
  • 2021-12-20
  • 2021-06-11
  • 2021-12-19
相关资源
相似解决方案