如果您没有使用FilePicker。IFilePickerSupport(),然后将其设置为空
喜欢
reader.Adapter = new MuPDFPageAdapter(this, null , core);
第二件事是你们的代码对我很有帮助,你们面临的问题,但你们的问题是我在我的项目中的解决方案,所以谢谢你们。
尝试一下,它会起作用,我在我的代码中使用它,它对我很有用。
最后一件事是对不起我的英语。
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
File fileToDisplay = (File)fileFromAsset(this, "test.pdf");
fileToDisplay.SetWritable(true);
RelativeLayout mupdfWrapper = FindViewById<RelativeLayout>(Resource.Id.mupdf_wrapper);
MuPDFCore core = new MuPDFCore(this, fileToDisplay.AbsolutePath);
MuPDFReaderView reader = new MuPDFReaderView(this);
MuPDFPageAdapter adapter = new MuPDFPageAdapter(this, null, core);
reader.SetAdapter(adapter);
mupdfWrapper.AddView(reader);
}
private object fileFromAsset(Context context, string assetName)
{
File outFile = new File(context.CacheDir, assetName);
copy(context.Assets.Open(assetName), outFile);
return outFile;
}
private void copy(Stream inputStream, File output)
{
OutputStream outputStream = null;
var bufferedInputStream = new BufferedInputStream(inputStream);
try
{
outputStream = new FileOutputStream(output);
int read = 0;
byte[] bytes = new byte[1024];
while ((read = bufferedInputStream.Read(bytes)) != -1)
{
outputStream.Write(bytes, 0, read);
}
}
finally
{
try
{
if (inputStream != null)
{
inputStream.Close();
inputStream.Dispose();
inputStream = null;
}
}
finally
{
if (outputStream != null)
{
outputStream.Close();
outputStream.Dispose();
outputStream = null;
}
}
}
}