collect_app/src/main/java/org/odk/collect/android/activities/PrintFormInstanceActivity.java
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getWindow().requestFeature(Window.FEATURE_PROGRESS);

        WebView webview = new WebView(this);
        setContentView(webview);

        //Reading XSLT
        String strXSLT = GetStyleSheet(R.raw.xsltfile);

        //Reading XML

        File InstanceXmlFile = Collect.getInstance().getFormController().getInstanceFile();

        String strXML = null;
        try {
            strXML = FileUtils.readFileToString(InstanceXmlFile, "utf-8");
        } catch (IOException e) {
            e.printStackTrace();
        }


        //Transform ...
        String html = StaticTransform(strXSLT, strXML);


        //Loading the above transformed XSLT in to Webview...
        webview.loadData(html, "text/html", null);


        WebView webView = new WebView(this);
        webView.setWebViewClient(new WebViewClient() {

            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return false;
            }

            @Override
            public void onPageFinished(WebView view, String url) {
                Log.i(TAG, "page finished loading " + url);
                createWebPrintJob(view);
                mWebView = null;
            }
        });

        webView.loadDataWithBaseURL(null, html, "text/HTML", "UTF-8", null);

        mWebView = webView;


    }
/**
     * Called when the activity is first created.
     */
Called when the activity is first created.
Called when the activity is first created .
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().requestFeature(Window.FEATURE_PROGRESS);
        WebView webview = new WebView(this);
        setContentView(webview);
        String strXSLT = GetStyleSheet(R.raw.xsltfile);
        File InstanceXmlFile = Collect.getInstance().getFormController().getInstanceFile();
        String strXML = null;
        try {
            strXML = FileUtils.readFileToString(InstanceXmlFile, "utf-8");
        } catch (IOException e) {
            e.printStackTrace();
        }
        String html = StaticTransform(strXSLT, strXML);
        webview.loadData(html, "text/html", null);
        WebView webView = new WebView(this);
        webView.setWebViewClient(new WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return false;
            }
            @Override
            public void onPageFinished(WebView view, String url) {
                Log.i(TAG, "page finished loading " + url);
                createWebPrintJob(view);
                mWebView = null;
            }
        });
        webView.loadDataWithBaseURL(null, html, "text/HTML", "UTF-8", null);
        mWebView = webView;
    }
@ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; getWindow ( ) . requestFeature ( Window . FEATURE_PROGRESS ) ; WebView webview = new WebView ( this ) ; setContentView ( webview ) ; String strXSLT = GetStyleSheet ( R . raw . xsltfile ) ; File InstanceXmlFile = Collect . getInstance ( ) . getFormController ( ) . getInstanceFile ( ) ; String strXML = null ; try { strXML = FileUtils . readFileToString ( InstanceXmlFile , "utf-8" ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } String html = StaticTransform ( strXSLT , strXML ) ; webview . loadData ( html , "text/html" , null ) ; WebView webView = new WebView ( this ) ; webView . setWebViewClient ( new WebViewClient ( ) { public boolean shouldOverrideUrlLoading ( WebView view , String url ) { return false ; } @ Override public void onPageFinished ( WebView view , String url ) { Log . i ( TAG , "page finished loading " + url ) ; createWebPrintJob ( view ) ; mWebView = null ; } } ) ; webView . loadDataWithBaseURL ( null , html , "text/HTML" , "UTF-8" , null ) ; mWebView = webView ; }
Called when the activity is first created.
Called when the activity is first created .
//Reading XSLT //Reading XML //Transform ... //Loading the above transformed XSLT in to Webview...