我想构建一个简单的壁纸应用程序,但只是无法设置壁纸。我已经尝试了很多方法,但却无法理解如何实现wallpapermanager。
final LinearLayout L1 = (LinearLayout) findViewById(R.id.l1);
final ImageView I1 = (ImageView) findViewById(R.id.imageView);
ImageView I2 = (ImageView) findViewById(R.id.imageView2);
ImageView I3 = (ImageView) findViewById(R.id.imageView3);
ImageView I4 = (ImageView) findViewById(R.id.imageView4);
ImageView I5 = (ImageView) findViewById(R.id.imageView5);
ImageView I6 = (ImageView) findViewById(R.id.imageView6);
ImageView I7 = (ImageView) findViewById(R.id.imageView7);
ImageView I8 = (ImageView) findViewById(R.id.imageView8);
ImageView I9 = (ImageView) findViewById(R.id.imageView9);
ImageView I10 = (ImageView) findViewById(R.id.imageView10);
ImageView I11 = (ImageView) findViewById(R.id.imageView11);
ImageView I12 = (ImageView) findViewById(R.id.imageView12);
ImageView I13 = (ImageView) findViewById(R.id.imageView13);
ImageView I14 = (ImageView) findViewById(R.id.imageView14);
Button b1 = (Button) findViewById(R.id.button);
final WallpaperManager my = WallpaperManager.getInstance(getApplicationContext());
I1.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View v) {
{
/*abc = 1;
if(abc==1) {
L1.setVisibility(View.GONE);
abc = 0;
}*/
}
}
}
);
I2.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View v) {
I1.setBackground(getDrawable(p));
}
}
);
I3.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View v) {
I1.setBackground(getDrawable(r));
}
}
);
I4.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View v) {
I1.setBackground(getDrawable(s));
}
}
);
I5.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View v) {
I1.setBackground(getDrawable(t));
}
}
);
I6.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View v) {
I1.setBackground(getDrawable(u));
}
}
);
I7.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View v) {
I1.setBackground(getDrawable(t));
}
}
);
I8.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View v) {
I1.setBackground(getDrawable(s));
}
}
);
I9.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View v) {
I1.setBackground(getDrawable(w));
}
}
);
I10.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View v) {
I1.setBackground(getDrawable(x));
}
}
);
I11.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View v) {
I1.setBackground(getDrawable(y));
}
}
);
I12.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View v) {
I1.setBackground(getDrawable(z));
}
}
);
I13.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View v) {
I1.setBackground(getDrawable(zz));
}
}
);
I14.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View v) {
I1.setBackground(getDrawable(xx));
}
}
);
b1.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View v) {
my.setResource(R.drawable.);
}
}
);