5: Test AppΒΆ

The app is ready to run, start it by clicking the green play button in the toolbar.

../../_images/getting_started--python_activity--05_test_app--01_run_app.png ../../_images/getting_started--python_activity--05_test_app--02_app.png

Now that the app is up & running, we can interact with the layout from the activity.

Open PythonActivity/app/src/main/res/layout/activity_main.xml and add the following code:

@ TextView:

android:id = "@+id/label"
../../_images/getting_started--python_activity--05_test_app--03_layout.png

Open PythonActivity/app/src/main/python/demo/chaquopy/pythonactivity/main_activity.py and add the following code:

@ MainActivity.onCreate:

label = self.findViewById(R.id.label)
label.setText("Python Activity Loaded!")
../../_images/getting_started--python_activity--05_test_app--04_activity.png

Now when we run the app again, the label is updated by the activity:

../../_images/getting_started--python_activity--05_test_app--05_app.png