Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.phi.myapplication6;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.widget.TextView;
- import android.widget.Button;
- import android.util.Log;
- import android.view.View;
- public class MainActivity extends AppCompatActivity {
- // Used to load the 'native-lib' library on application startup.
- static {
- System.loadLibrary("native-lib");
- }
- private TextView tv;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- // Example of a call to a native method
- tv = (TextView) this.findViewById(R.id.sample_text);
- tv.setText(stringFromJNI());
- // Lấy ra button theo ID
- Button button1 = (Button) this.findViewById(R.id.button1);
- // Sét đặt sự kiện Click vào Button1.
- button1.setOnClickListener(new Button.OnClickListener() {
- @Override
- public void onClick(View view) {
- tv.setText("Result: " + getStringRandom());
- }
- });
- }
- /**
- * A native method that is implemented by the 'native-lib' native library,
- * which is packaged with this application.
- */
- public native String stringFromJNI();
- public native String getStringRandom();
- }
Add Comment
Please, Sign In to add comment