Web/Android/iOS-内部链接-寻找想法/解决方案



我将首先描述我们现在拥有的:

  • CMS-用药物描述填充数据库。药品名称为文本框和CKEditor,用于HTML格式的描述
  • WCF-将数据库导出为JSON
  • 安卓应用程序-药物列表,然后通过网络视图显示药物描述HTML格式

我们需要找到在药物描述中创建内部链接(即:药物名称)的解决方案,这将导致提到的药物描述页面。

有没有办法用我们目前的方法来实现这一点?

即使我找到了如何在CMS中创建此功能的方法(可能我会使用哈希标签来区分外部和内部链接),我仍然不知道如何在Android应用程序中获得此功能。

如果这是有风险的,或者很难将此功能添加到我们当前的设置中,你们至少可以告诉我应该如何构建以应用此内部链接功能。我以前从来没有这样做过,所以我甚至不知道从哪里开始。谢谢你的帮助。

让CMS中的链接具有自定义href格式,类似于drug://drugid

而不是在android应用程序中(加载描述的网络视图,覆盖shouldOverrideUrlLoading

webView.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url.startsWith("drug://")) {
            //this is where the click to that href will be intercepted
            //extract the id from url and do whatever you want with it
            return true; //disable the webview to load that url
        }
        return false;
    }
});

对于IOS设备,覆盖shouldStartLoadWithRequest:

- (BOOL)WebView:(UIWebView *)myWebView shouldStartLoadWithRequest:(NSURLRequest *)request          navigationType:(UIWebViewNavigationType)navigationType {
    if([[request.URL absoluteString] hasPrefix:@"drug://"]) {
        //this is where the click to that href will be intercepted
        //extract the id from url and do whatever you want with it
        return NO;  //disable the webview to load that url
    }
    return YES;
}

相关内容

最新更新