chaguopy控件交互

cooolr 于 2022-06-24 发布
from android.os import Bundle
from android.view import View
from java import method
from android.widget import Button
from androidx.appcompat.app import AppCompatActivity
from com.chaquo.python.hello import R
from java import jvoid, Override, static_proxy

class MainActivity(static_proxy(AppCompatActivity)):

    @Override(jvoid, [Bundle])
    def onCreate(self, state):
        AppCompatActivity.onCreate(self, state)
        self.setContentView(R.layout.activity_main)
        self.findViewById(R.id.textview).setText("hahaha")

    @method(jvoid, [View])
    def onClick(self, v):
        text = self.findViewById(R.id.textview).getText()
        self.findViewById(R.id.textview).setText("hahaha2")