http://www.cnblogs.com/jk1001/archive/2010/08/05/1793216.html 手工编译android
http://www.moandroid.com/?p=712 OpenGL创建流程
http://blog.163.com/my_appy@126/blog/static/118323971200953061819702/ 贝塞尔曲线
http://hi.baidu.com/lsjsuper/blog/item/4ca2c2773584ef08b051b9bd.html
void lookAt(float eyex, float eyey, float eyez,
float orgx, float orgy, float orgz,
float upx, float upy, float upz)
{
//Calculate eye direction vector
float vpnx = orgx - eyex;
float vpny = orgy - eyey;
float vpnz = orgz - eyez;
//Normalize it
float len = sqrt(vpnx * vpnx + vpny * vpny + vpnz * vpnz);
vpnx /= len;
vpny /= len;
vpnz /= len;
//Calculate right vector
float rvx = vpny * upz - vpnz * upy;
float rvy = vpnz * upx - vpnx * upz;
float rvz = vpnx * upy - vpny * upx;
//Calculate new up vector
float nux = rvy * vpnz - rvz * vpny;
float nuy = rvz * vpnx - rvx * vpnz;
float nuz = rvx * vpny - rvy * vpnx;
//Put it all in a pretty Matrix
float mat[16] = {
rvx, nux, -vpnx, 0,
rvy, nuy, -vpny, 0,
rvz, nuz, -vpnz, 0,
0, 0, 0, 1
};
//Apply the matrix and translate to eyepoint
glMultMatrixf(mat);
glTranslatef(-eyex, -eyey, -eyez);
}
void display (void) {
glClear
public class Main extends Activity { int[] imgIds = { // 图片资源的id数组 R.drawable.w1, R.drawable.w2, R.drawable.w3, R.drawable.w4 }; int setImgID = -1; // 被选中的图片在id数组中的索引 BaseAdapter ba = new BaseAdapter() { // 自定义的BaseAdapter public View getView(int position, View convertView, ViewGroup parent) { ImageView iv = new ImageView(Main.this); // 新建一个ImageView iv.setBackgroundResource(imgIds[position]); // 设置ImageView的背景图片 iv.setScaleType(ImageView.ScaleType.CENTER_CROP); iv.setLayoutParams(new Gallery.LayoutParams(120, 120)); // 设置相框中元素的大小 return iv; } public long getItemId(int arg0) { return 0; } public Object getItem(int arg0) { return null; } public int getCount() { return imgIds.length; } }; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); findViewById(R.id.clearWall).setOnClickListener( new View.OnClickListener() { public void onClick(View v) { // 重写onClick方法 try { Main.this.clearWallpaper(); // 还原手机壁纸 } catch (IOException e) { // 捕获并打印异常 e.printStackTrace(); } } }); findViewById(R.id.getWall).setOnClickListener( new View.OnClickListener() { // 为Button添加OnClickListener监听器 public void onClick(View v) { ImageView iv = (ImageView) findViewById(R.id.currWall); iv.setBackgroundDrawable(getWallpaper()); // 设置ImageView显示的内容为当前墙纸 } }); Gallery g = (Gallery) findViewById(R.id.gallery); // 获得Gallery对象 g.setAdapter(ba); // 设置Gallery的BaseAdapter g.setSpacing(5); // 设置每个元素之间的间距 g.setOnItemClickListener(new OnItemClickListener() { // 为Gallery添加OnItemClickListener监听器 public void onItemClick(AdapterView<?> parent, View v, int position, long id) { setImgID = position; // 记录被选中的图片索引 } }); findViewById(R.id.setWall).setOnClickListener( new View.OnClickListener() { // 为Button添加OnClickListener监听器 public void onClick(View v) { // 重写onClick方法 Resources r = Main.this.getResources(); // 获得Resources对象 InputStream in = r.openRawResource(imgIds[setImgID]);// 获得InputStream对象 try { setWallpaper(in); // 设置墙纸 } catch (IOException e) { e.printStackTrace(); } } }); } }
权限配置:
<uses-permission android:name="android.permission.SET_WALLPAPER" />
public class Main extends Activity { Vibrator vibrator; // 声明一个Vibrator对象 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); vibrator = (Vibrator) getSystemService(Service.VIBRATOR_SERVICE); // 创建Vibrator对象 ((CompoundButton) findViewById(R.id.tb1)) .setOnCheckedChangeListener(new OnCheckedChangeListener() { // 设置OnCheckedChangeListener监听器 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // 重写onCheckedChanged方法 if (isChecked) { // 判断ToggleButton的选中状态 vibrator.vibrate( new long[] { 1000, 50, 50, 100, 50 }, -1); // 启动振动 TextView tv1 = (TextView) findViewById(R.id.tv1); // 获得TextView tv1.setText(R.string.vibrateOn); // 设置TextView控件内容 } else { vibrator.cancel(); // 关闭振动 TextView tv1 = (TextView) findViewById(R.id.tv1); // 获得TextView tv1.setText(R.string.vibrateOff); // 设置TextView控件内容 } } }); ((CompoundButton) findViewById(R.id.tb2)) .setOnCheckedChangeListener(new OnCheckedChangeListener() { // 设置OnCheckedChangeListener监听器 @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { // 判断ToggleButton的选中状态 vibrator.vibrate(2500); // 启动振动 ((TextView) findViewById(R.id.tv2)) .setText(R.string.vibrateOn); } else { vibrator.cancel(); // 关闭振动 ((TextView) findViewById(R.id.tv2)) .setText(R.string.vibrateOff); } } }); } }
<uses-permission android:name="android.permission.VIBRATE" />