Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
931 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...