Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android studio 为什么我的pdf文件在运行时无法工作或显示?_Android Studio - Fatal编程技术网

Android studio 为什么我的pdf文件在运行时无法工作或显示?

Android studio 为什么我的pdf文件在运行时无法工作或显示?,android-studio,Android Studio,为什么我的pdf文件在运行时无法工作或显示?我将pdf文件包括在我的资产文件夹中 但它仍然不起作用。为什么会这样?将pdf添加到资产文件夹是否有任何限制。我正在开发一个应用程序,将包含超过20个pdf。目前,我已经在我的资产文件夹中包含了25个pdf文件。其他pdf正在工作,但只有以下活动pdf不工作为什么会这样 这是PDFCE4Activity.java ```包com.example.easylearn; 导入androidx.annotation.NonNull; 导入androidx.a

为什么我的pdf文件在运行时无法工作或显示?我将pdf文件包括在我的资产文件夹中 但它仍然不起作用。为什么会这样?将pdf添加到资产文件夹是否有任何限制。我正在开发一个应用程序,将包含超过20个pdf。目前,我已经在我的资产文件夹中包含了25个pdf文件。其他pdf正在工作,但只有以下活动pdf不工作为什么会这样

这是PDFCE4Activity.java
```包com.example.easylearn;
导入androidx.annotation.NonNull;
导入androidx.annotation.Nullable;
导入androidx.appcompat.app.appcompat活动;
导入android.app.Activity;
导入android.content.Intent;
导入android.os.Bundle;
导入android.util.Log;
导入android.view.view;
导入android.view.ViewGroup;
导入android.widget.AdapterView;
导入android.widget.ArrayAdapter;
导入android.widget.Button;
导入android.widget.ListView;
导入android.widget.TextView;
导入com.github.barteksc.pdfviewer.PDFView;
导入com.github.barteksc.pdfviewer.listener.OnLoadCompleteListener;
导入com.github.barteksc.pdfviewer.listener.OnPageChangeListener;
导入com.github.barteksc.pdfviewer.scroll.DefaultScrollHandle;
导入com.shockwave.pdfium.PdfDocument;
导入com.google.firebase.auth.FirebaseAuth;
导入java.util.List;
公共类PDFCE4Activity扩展了AppCompatActivity{
列表视图pdflistview;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pdfce4);
pdflistview=(ListView)findViewById(R.id.myPDFlist4);
字符串[]easylearn={“高性能计算”、“人工智能”、“数字信号”
处理“};
ArrayAdapter适配器=新的ArrayAdapter
(这是android.R.layout.simple\u list\u item\u 1,easylearn){
@非空
@凌驾
公共视图getView(int位置,@Nullable视图convertView,@NonNull视图组父级){
视图=super.getView(位置、转换视图、父级);
TextView myText=(TextView)view.findviewbyd(android.R.id.text1);
返回视图;
}
};
pdflistview.setAdapter(适配器);
pdflistview.setOnItemClickListener(新的AdapterView.OnItemClickListener(){
@凌驾
公共无效onItemClick(AdapterView AdapterView、View视图、int i、long l){
String item=pdflistview.getItemAtPosition(i).toString();
Intent start=newintent(getApplicationContext(),PDFCE3Opener.class);
start.putExtra(“pdfFileName”,项目);
起始触觉;
}
});
}
}```
这是我的PDFCE4Opener.xml
```包com.example.easylearn;
导入androidx.appcompat.app.appcompat活动;
导入android.os.Bundle;
导入com.github.barteksc.pdfviewer.PDFView;
公共类PDFCE4Opener扩展了AppCompatActivity{
PDFView myPDFViewer3;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pdfce4_opener);
myPDFViewer3=(PDFView)findViewById(R.id.pdfViewer3);
字符串getItem=getIntent().getStringExtra(“PdfileName”);
if(getItem.equals(“高性能计算”)){
myPDFViewer3.fromAsset(“High-Performance Computing.pdf”).load();
}
if(getItem.equals(“人工智能”)){
myPDFViewer3.fromAsset(“rich and knight.pdf提供的人工智能”).load();
}
if(getItem.equals(“数字信号处理”)){
myPDFViewer3.fromAsset(“Digital Signal Processing.pdf”).load();
}
}
}```    
这是我的活动_pdfce4.xml
```
```
这是我的活动_pdfce4 _opener.xml
``` 
```

您遇到了什么错误?不活动,当我单击特定的PDFCA时断开了与服务的连接。您能告诉我哪里出错了吗?这是否回答了您的问题?但我没有发现问题出在哪里?
This is PDFCE4Activity.java
```package com.example.easylearn;

 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.appcompat.app.AppCompatActivity;

 import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.AdapterView;
 import android.widget.ArrayAdapter;
 import android.widget.Button;
 import android.widget.ListView;
  import android.widget.TextView;

 import com.github.barteksc.pdfviewer.PDFView;
 import com.github.barteksc.pdfviewer.listener.OnLoadCompleteListener;
 import com.github.barteksc.pdfviewer.listener.OnPageChangeListener;
  import com.github.barteksc.pdfviewer.scroll.DefaultScrollHandle;
   import com.shockwave.pdfium.PdfDocument;
 import com.google.firebase.auth.FirebaseAuth;

     import java.util.List;
     public class PDFCE4Activity extends AppCompatActivity {

  ListView pdflistview;
  @Override
   protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pdfce4);

    pdflistview = (ListView) findViewById(R.id.myPDFlist4);
    String[] easylearn  = {"High Performance Computing","Artificial Intelligence","Digital Signal 
    Processing"};
    ArrayAdapter<String> adapter = new ArrayAdapter<String> 
    (this,android.R.layout.simple_list_item_1,easylearn){
        @NonNull
        @Override
        public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent){
            View view = super.getView(position,convertView,parent);
            TextView myText = (TextView) view.findViewById(android.R.id.text1);
            return view;
        }
    };

    pdflistview.setAdapter(adapter);
    pdflistview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            String item = pdflistview.getItemAtPosition(i).toString();

            Intent start = new Intent(getApplicationContext(),PDFCE3Opener.class);
            start.putExtra("pdfFileName",item);
            startActivity(start);
        }
        });
        }
        }```

     This is my PDFCE4Opener.xml
     ```package com.example.easylearn;

      import androidx.appcompat.app.AppCompatActivity;

      import android.os.Bundle;

      import com.github.barteksc.pdfviewer.PDFView;

       public class PDFCE4Opener extends AppCompatActivity {

      PDFView myPDFViewer3;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pdfce4_opener);

     myPDFViewer3 = (PDFView) findViewById(R.id.pdfViewer3);
     String getItem = getIntent().getStringExtra("pdfFileName");

      if(getItem.equals("High Performance Computing")){
        myPDFViewer3.fromAsset("High Performance Computing.pdf").load();
    }

    if(getItem.equals("Artificial Intelligence")){
        myPDFViewer3.fromAsset("artificial-intelligence-by-rich-and-knight.pdf").load();
    }

    if(getItem.equals("Digital Signal Processing")){
        myPDFViewer3.fromAsset("Digital Signal Processing.pdf").load();
    }
  }
 }```    

 This is my activity_pdfce4.xml
 ```<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
tools:context=".PDFCE4Activity">

  <ListView
    android:id="@+id/myPDFlist4"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="20dp">

  </ListView>
 </RelativeLayout>```

 This is my activity_pdfce4_opener.xml
 ``` <?xml version="1.0" encoding="utf-8"?>
     <androidx.constraintlayout.widget.ConstraintLayout 
     xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
       tools:context=".PDFCE4Opener">

      <com.github.barteksc.pdfviewer.PDFView
      android:id="@+id/pdfViewer3"
      android:layout_width="match_parent"
      android:layout_height="match_parent">
      </com.github.barteksc.pdfviewer.PDFView>

      </androidx.constraintlayout.widget.ConstraintLayout>```