我有一个扩展Fragment的第一个类,以及扩展Activity的第二个类.
我的片段工作正常,片段中的Intent代码是:
ImageButton button= (ImageButton) getView().findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(MyFragment.this, MyClass.class);
MyFragment.this.startActivity(myIntent); }
});
Run Code Online (Sandbox Code Playgroud)
我的MyClass类代码是:
public class MyClass extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// The activity is being created.
}
@Override
protected void onStart() {
super.onStart();
setContentView(R.layout.MyClass);
}
}
Run Code Online (Sandbox Code Playgroud)
错误是:
Gradle: cannot find symbol constructor Intent(com.xxxx.xxxx.MyFragment,java.lang.Class<com.xxxx.xxxx.MyClass>)
我不知道哪里出错了.
这是我用来允许证书的代码:
@interface NSURLRequest(DummyInterface)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString*)host;
+ (void)setAllowsAnyHTTPSCertificate:(BOOL)allow forHost:(NSString*)host;
@end
@implementation NSURLRequest(DummyInterface)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
return [host isEqualToString:@"mysite.com"];
}
@end
Run Code Online (Sandbox Code Playgroud)
我初始化我的WKWebView:
NSURL *urlReq = [NSURL URLWithString:@"mysite.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:urlReq];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[urlReq host]];
WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];
mainWebView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration];
[mainWebView setNavigationDelegate:self];
[mainWebView loadRequest:request];
Run Code Online (Sandbox Code Playgroud)
它适用于http网站,但我使用https有这个错误:
此服务器的证书无效.您可能正在连接到假装为"mysite.com"的服务器,这可能会使您的机密信息面临风险.
当我使用UIWebView并实现"canAuthenticateAgainstProtectionSpace"功能时,它正在工作,但现在我不明白我必须做什么.
我错过了什么或WKWebView无法处理HTTPS?
我是一个新的Android开发人员,所以我更喜欢询问正确的方法以解决我的问题.
我有一个FragmentActivity和多个片段,我的一个片段是按钮的组合,应该在iOS上的导航控制器中显示新视图,如推送视图.
我试图创建新的活动,并用Intent显示它们,但是actionBar发现了.
那么我想创建什么来使用actionBar并保持我的操作栏?
先感谢您.