我只字不提。 我愿在
Here is a brief explanation (complete explanation below):
In short- I need a way to pass an image from my main activity to a dialog then on Cancel dismiss
the dialog and on confirm set the system wallpaper (to the image passed from the main activity) then finish();
the activity.
此处作完整解释:
用户名单见Gallery
和Gallery
,这表明对上重点的图像进行了较大的审查。 彩虹/代码。
在<代码>Gallery上展示的图像使用:
// setup wallpaper array
private void findWallpapers() {
mThumbs = new ArrayList<Integer>(24);
mImages = new ArrayList<Integer>(24);
final Resources resources = getResources();
final String packageName = getApplication().getPackageName();
addWallpapers(resources, packageName, R.array.wallpapers);
}
// setup array defining all wallpapers & define thumbnails
private void addWallpapers(Resources resources, String packageName, int list) {
final String[] extras = resources.getStringArray(list);
for (String extra : extras) {
int res = resources.getIdentifier(extra, "drawable", packageName);
if (res != 0) {
final int thumbRes = resources.getIdentifier(extra + "_small",
"drawable", packageName);
if (thumbRes != 0) {
mThumbs.add(thumbRes);
mImages.add(res);
}
}
}
}
在“Set Wallpaper”Button
上报后,AlertDialog
应当与另一个版面图相提并存,该图文在Gallery
上。
再次感谢!
private void selectWallpaper(int position) {
Toast.makeText(getBaseContext(), "Select Wallpaper", Toast.LENGTH_SHORT)
.show();
if (mIsWallpaperSet) {
return;
}
mIsWallpaperSet = true;
Context context = this;
// CharSequence text = "Wallpaper Set!";
// int duration = Toast.LENGTH_LONG;
InputStream stream = getResources().openRawResource(
mImages.get(position));
final Dialog accept = new Dialog(context);
accept.setContentView(R.layout.confirm);
accept.setTitle("Please Confirm");
TextView instructions = (TextView) accept.findViewById(R.id.textView1);
instructions.setText("Would you like to set this as your wallpaper?");
ImageView wallpreview = (ImageView) accept
.findViewById(R.id.imageView1);
wallpreview.createFromStream(stream, "test");
// SETUP cancel (no btn) listener
Button cancelbtn = (Button) accept.findViewById(R.id.button2);
cancelbtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
accept.dismiss();
}
});
// SETUP Yes Btn listener
Button okbtn = (Button) accept.findViewById(R.id.button1);
okbtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// dismiss being used as placeholder, actually setting wallpaper
// will be added
accept.dismiss();
}
});
accept.show();
}
{
;
}