基本上,我希望能够单击可以做2件事的WebView中的按钮
- 更改我的setContentView
- 运行我已经在Android中制作的相机例程(我想运行我在Android中运行的Android代码)
目前,我发现的所有资源似乎都与打开FileChooser有关P>
问题是使用JavaScript,我发现它不允许我执行setContentView(resource.layout.menu2)或MainAttivity之外的任何内容作为回电
我真的希望有人可以帮助
问题是使用JavaScript,我发现它不允许我执行setContentView(resource.layout.menu2)或MainAttivity之外的任何内容作为回电
问题是需要在UI线程上执行SetContentView
。因此,您需要使用活动。为此:
public class MyJSInterface:Java.Lang.Object
{
Activity context;
public MyJSInterface(Activity c)
{
context = c;
}
[Export]
[JavascriptInterface]
public void MyCallback()
{
//run the SetContentView on the UI Thread
context.RunOnUiThread(() => {
context.SetContentView(Resource.Layout.NewLayout);
});
}
}