0

我尝试将心爱的代码相同的转换为nativescript,但我是新手,我对此一无所知,请告诉我如何将android代码转换为nativescript ...

 private void createWebPrintJob() {

    // Get a PrintManager instance
    PrintManager printManager = (PrintManager)
            getSystemService(Context.PRINT_SERVICE);

    // Get a print adapter instance
    PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter();

    // Create a print job with name and adapter instance
    String jobName = getString(R.string.app_name) + " Document";
    PrintJob printJob = printManager.print(jobName, printAdapter,
            new PrintAttributes.Builder().build());

    // Save the job object for later status checking
    // mPrintJobs.add(printJob);
}
4

1 回答 1

1

可能是这样的,

var application = require('application');
var utils = require('utils/utils');

function createWebPrintJob() {
 var printManager = application.android.context
           .getSystemService(android.content.Context.PRINT_SERVICE);
 var printAdapter = webView.createPrintDocumentAdapter();
 var jobName = getString(utils.ad.getStringId("app_name")) + " Document";
 var printJob = printManager.print(jobName, printAdapter, new namespace.to.PrintAttributes.Builder().build());
 mPrintJobs.add(printJob);
}

以上只是 puedo 代码,归根结底它是 JavaScript,没什么特别的。

于 2018-03-04T22:29:48.973 回答