码迷,mamicode.com
首页 > 编程语言 > 详细

01_c++下jni开发说明

时间:2017-07-10 10:33:26      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:bsp   native   c++   mat   end   ocp   com   pac   creat   

技术分享

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="helloincpp"
        android:text="调用C++函数" />

</RelativeLayout>
package com.itheima.cppjni;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void helloincpp(View v){
        Toast.makeText(this, hellocpp(), Toast.LENGTH_SHORT).show();
    }
    public native String hellocpp();
}

Java的代码咱们就写好了.接下来是写C++的代码.


 

技术分享

Android Tools->Add Native Support

技术分享

技术分享

技术分享

 

01_c++下jni开发说明

标签:bsp   native   c++   mat   end   ocp   com   pac   creat   

原文地址:http://www.cnblogs.com/ZHONGZHENHUA/p/7143892.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!