我是android新手。在壁纸上开发应用程序。壁纸设置很好的背景。我想在其中编辑文本。例如,当我们单击按钮设置壁纸时,它应该在屏幕上显示壁纸设置的文本。 Plz有助于解决此问题。 这是主要的java。
public class Main extends Activity {
private ImageView hImageViewPic;
private Button iButton, gButton;
private int currentImage = 0;
int[] images = { R.drawable.r1, R.drawable.r2, R.drawable.r3, R.drawable.r4, R.drawable.r5, R.drawable.r6, R.drawable.r7, R.drawable.r8, R.drawable.r9, R.drawable.r10 };
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
hImageViewPic = (ImageView)findViewById(R.id.idImageViewPic);
iButton = (Button) findViewById(R.id.bNext);
gButton = (Button) findViewById(R.id.bPrev);
//Just set one Click listener for the image
iButton.setOnClickListener(iButtonChangeImageListener);
gButton.setOnClickListener(gButtonChangeImageListener);
}
View.OnClickListener iButtonChangeImageListener = new OnClickListener() {
public void onClick(View v) {
//Increase Counter to move to next Image
currentImage++;
currentImage = currentImage % images.length;
hImageViewPic.setImageResource(images[currentImage]);
}
};
View.OnClickListener gButtonChangeImageListener = new OnClickListener() {
`public void onClick(View v) {
//Increase Counter to move to next Image
currentImage--;
currentImage = (currentImage + images.length) % images.length;
hImageViewPic.setImageResource(images[currentImage]);
// Button for wallpaper setting
Button bSetWallpaper=(Button) findViewById (R.id.bSet);
imageView imagePreview=(imageView) findViewById(R.id.idImageViewPic);
imagePreview.setOnClickListener (images [currentImage]);
bSetWallper.setOnClickListener (new Button.onClickListener (){
@Override
public void onClick (View arg0){
WallpaperManager myWallpaperManager = WallpaperManager.getInstance (getApplicationContext ());
try {
myWallpaperManager.setResource (images [currentImage]);
} catch (IOException e) {
e.printStackTrace ();
}
}
});
}
};
}
所以plz帮助显示文本。 `
答案 0 :(得分:0)
你想要这样的东西吗?
Toast.makeText(getApplicationContext(), "Wallpaper set!", Toast.LENGTH_LONG).show();