Window下的开发环境
安装pydew插件PyDev2.6.0:
下载地址:
http://sourceforge.net/projects/pydev/files/
解压后将features和plugins放到eclipse同名目录下,亲一懂的
下载地址:
http://code.google.com/p/cle-for-android/downloads/detail?name=starcore_devfiles_r80.zip&can=2&q=
Wrapandroid.jar
下载地址:
在工程中导入starcore_devfiles_r7.jar和wrapandroid.jar
异入共享库文件,在~\python\starcore_devfiles_r7\so\armeabiv7a目录下的.so文件放到工程的(libs/armeabi)目录下
示例程序:
<?xmlversion="1.0"encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lay_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/txt_info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"/>
<Button
android:id="@+id/btn_click"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Pythonfirstdemo!"/>
</LinearLayout>
/**
*firstpythondemo
*
*@time下午12:00:39
*@authorretacnyue
*@Email[email protected]
*/
publicclassPythonDemoActivityextendsWrapAndroidActivity{
Buttonbtn_click;
TextViewtxv_info;
@Override
publicvoidonCreate(BundlesavedInstanceState){
DownloadFromNetFlag=false;
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//这是加载库文件
//StarActivity._Call("DoFile","",
//"/data/data/"+getPackageName()+"/lib/libCode.so");
StarActivity._Call("DoAssetsFile","python","pythontest.py");
//findView(); }
/**
*实例化控件
*/
@SuppressWarnings("unused")
privatevoidfindView(){
txv_info=(TextView)this.findViewById(R.id.txt_info);
btn_click=(Button)this.findViewById(R.id.txt_info);
}
}
Pythontest.py文件(assets目录下)
SrvGroup=libstarpy._GetSrvGroup()
Service=SrvGroup._GetService("","")
StarActivity=Service.ActivityClass.getCurrent();
MyText=StarActivity.findViewById("TextViewClass",StarActivity.getResource("id/txt_info"));
MyText.setText("fromlayout");
MyButton=StarActivity.findViewById("ButtonClass",StarActivity.getResource("id/btn_click"));
defMyButton_onClick(self,Ev):
Service.ToastClass._New().makeText("Buttonclicked",1).show();
MyButton.onClick=MyButton_onClick;
MyButton.setOnClickListener();
MyLinearLayout=StarActivity.findViewById("LinearLayoutClass",StarActivity.getResource("id/lay_main"));
MyDynaButton=Service.ButtonClass._New(MyLinearLayout);
defMyDynaButton_onClick(self,Ev):
Service.ToastClass._New().makeText("MyDynaButtonclicked",1).show();
MyDynaButton.onClick=MyDynaButton_onClick;
MyDynaButton.setOnClickListener();
MyDynaButton.setText("createddynamically");
MyDynaButton.setLinearLayoutParams(300,80);