package net.npaka.wallpaperex;
import android.app.Activity;
import android.content.Intent;
import android.graphics.*;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
//壁紙の変更
public class WallpaperEx extends Activity
implements View.OnClickListener {
private final static int WC=LinearLayout.LayoutParams.WRAP_CONTENT;
//初期化
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
//レイアウトの生成
LinearLayout layout=new LinearLayout(this);
layout.setBackgroundColor(Color.TRANSPARENT);
layout.setOrientation(LinearLayout.VERTICAL);
setContentView(layout);
//ボタンの生成
Button button=new Button(this);
button.setText("壁紙変更");
button.setOnClickListener(this);
button.setLayoutParams(new LinearLayout.LayoutParams(WC,WC));
layout.addView(button);
}
//ボタンクリック時に呼ばれる
public void onClick(View v) {
//壁紙変更
Intent pickWallpaper=new Intent(
Intent.ACTION_SET_WALLPAPER);
startActivity(Intent.createChooser(
pickWallpaper,getString(R.string.app_name)));
}
} |