Android NDK入门、提高和实战
2010-08-21 06:22:00 来源:WEB开发网核心提示:b.x = 5;b.y = 5;float d = distance(a,b);tv.setText("distance(a,b):"+d);setContentView(tv);}public native float distance(Point a, Point b);static {Syst
b.x = 5;
b.y = 5;
float d = distance(a,b);
tv.setText("distance(a,b):"+d);
setContentView(tv);
}
public native float distance(Point a, Point b);
static {
System.loadLibrary("demo");
}
}
public class Main extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(getApplicationContext());
Point a = new Point();
a.x = 3;
a.y = 3;
Point b = new Point();
b.x = 5;
b.y = 5;
float d = distance(a,b);
tv.setText("distance(a,b):"+d);
setContentView(tv);
}
public native float distance(Point a, Point b);
static {
System.loadLibrary("demo");
}
}
运行,得到结果distance(a,b):2.828427
更多精彩
赞助商链接