Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
902 views
in Technique[技术] by (71.8m points)

java - Load PowerPoint file in Android

I am trying to make a PPT viewer app.I have added the pptViewer library in my project from https://github.com/itsrts/pptviewer-android. But I am getting an error called "cannot resolve symbol 'activity'" on this line pptViewer.loadPPT(activity,"/home/waheed/lab6.pptx").Please help. Below is my code:

   package com.example.waheed.myapplication;

   import android.support.v7.app.AppCompatActivity;
   import android.os.Bundle;

   import com.itsrts.pptviewer.PPTViewer;

   public class MainActivity extends AppCompatActivity {

   @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    PPTViewer pptViewer = (PPTViewer) findViewById(R.id.pptviewer);
    pptViewer.setNext_img(R.drawable.next)
            .setPrev_img(R.drawable.prev)
            .setSettings_img(R.drawable.settings)
            .setZoomin_img(R.drawable.zoomin)
            .setZoomout_img(R.drawable.zoomout);
    pptViewer.loadPPT(activity,"/home/waheed/lab6.pptx");
}
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

activity isn't a defined symbol, but . In this case, since the code is in an activity, use the current object:

pptViewer.loadPPT(this, "/home/waheed/lab6.pptx");

You probably copy-pasted from the readme, as the activity used as sample method input in the readme means you have to pass an activity instance. You don't declare Activity activity = ..., but since you're in an activity you can use this


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...