2014-04-10 1 views
0

나는 pdfView 라이브러리로 시도하고 pdfviewlibrary 항아리와 모든 것을 추가했습니다. 그러나 "Loading PDF page"만 보여줍니다. 자산 폴더에 내 PDF 파일이 있습니다.저는 Pdf 뷰어 라이브러리를 사용하여 Pdf 파일을 엽니 다. 그것은 오랫동안 PDF 로딩을 보여줍니다

해결책을 찾는데 도움이 될만한 자료가 있습니까? 내가

감사

package com.example.pdfviewer; 

import android.os.Bundle; 
import android.app.Activity; 
import android.view.Menu; 

public class MainActivity extends PdfViewerActivity { 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     //setContentView(R.layout.activity_main); 
    } 

    public int getPreviousPageImageResource() { return R.drawable.left_arrow; } 
    public int getNextPageImageResource() { return R.drawable.right_arrow; } 
    public int getZoomInImageResource() { return R.drawable.zoom_in; } 
    public int getZoomOutImageResource() { return R.drawable.zoom_out; } 
    public int getPdfPasswordLayoutResource() { return R.layout.pdf_file_password; } 
    public int getPdfPageNumberResource() { return R.layout.dialog_pagenumber; } 
    public int getPdfPasswordEditField() { return R.id.etPassword; } 
    public int getPdfPasswordOkButton() { return R.id.btOK; } 
    public int getPdfPasswordExitButton() { return R.id.btExit; } 
    public int getPdfPageNumberEditField() { return R.id.pagenum_edit; } 

} 
+0

콘텐츠를 정의하지 않았습니까? 공식 README는 귀하의 레이아웃을 추가하도록 지시합니다 : https://github.com/JoanZapata/android-pdfview – shkschneider

답변

0

나는 또한 동일한 문제가 무엇입니까하지만 난 그것을 해결 아래 내 코드를 언급 ... 하여 주어진 코드는 단지의 경로를 확인한다는 점에서 문제가없는 정확 당신이 가져 가고있는 파일이 맞는지 아닌지. 내 프로젝트에서 나는 그 시점에서 실수를해서 문제가 해결 될 수 있습니다. 참조 용으로 내 코드를 제공하고 있습니다 ...

private File currentDir; 
private FileArrayAdapter file_adapter; 
String path; 

@SuppressLint("SdCardPath") @Override 
public void onClick(View v) { 
    // TODO Auto-generated method stub 

    currentDir = new File("/sdcard/"); 
    fill(currentDir); 


} 

@SuppressLint("SdCardPath") private void fill(File f) 
    { 
     File[]dirs = f.listFiles(); 


     Faculty_Notes.this.setTitle("Current Dir: "+f.getName()); 
     List<Option>dir = new ArrayList<Option>(); 
     List<Option>fls = new ArrayList<Option>(); 
     try{ 
      for(File ff: dirs) 
      { 
       if(ff.isDirectory()) 
        dir.add(new    Option(ff.getName(),"Folder",ff.getAbsolutePath())); 
       else 
       { 
        if(ff.getName().endsWith(".pdf")) 
        { 
         fls.add(new Option(ff.getName(),"File Size: "+ff.length(),ff.getAbsolutePath())); 
        } 

       } 
      } 
     }catch(Exception e) 
     { 
      e.printStackTrace(); 
     } 
     Collections.sort(dir); 
     Collections.sort(fls); 
     dir.addAll(fls); 
     if(!f.getName().equalsIgnoreCase("/sdcard")) 
      dir.add(0,new Option("..","Parent Directory",f.getParent())); 
     file_adapter = new FileArrayAdapter(Faculty_Notes.this,R.layout.file_view,dir); 
     Faculty_Notes.this.setListAdapter(file_adapter); 
    } 
    @Override 
    protected void onListItemClick(ListView lv, View v, int position, long id) { 
     // TODO Auto-generated method stub 
     super.onListItemClick(lv, v, position, id); 
     Option o = file_adapter.getItem(position); 
      if(o.getData().equalsIgnoreCase("folder")||o.getData().equalsIgnoreCase("parent directory")){ 
       currentDir = new File(o.getPath()); 
       fill(currentDir); 
     } 
     else 
     { 
      onFileClick(o); 
     } 
    } 
    private void onFileClick(Option o) 
    { 
     path = o.getPath(); 
     openPdfIntent(path); 
    } 
    private void openPdfIntent(String path) { 
     try { 
     final Intent intent = new Intent(Faculty_Notes.this, Second.class); 
     intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, path); 
     startActivity(intent); 
     } catch (Exception e) { 
     e.printStackTrace(); 
     } 
    } 

또한 Second.class 파일에는 위에서 지정한 코드가 들어 있습니다.

희망이 있으면 행운을 빌 수 있습니다.