0

I am a beginner and I am asking this just to gain knowledge. so in my app, I have a MainActivity And its layout activity_main.xml.

here is the code of activity main

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.testapp.myapp.MainActivity">

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Button 1"
    android:id="@+id/btn1"/>

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/btn1"
    android:text="Button 2"
    android:id="@+id/btn2"/> </RelativeLayout>

And here is the MainActivity.java

package com.testapp.myapp;

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

public class MainActivity extends Activity {

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

I Have created Two Blank activities named By Button1PDF And Button2PDF And Each Has layout named button1_pdf.xml and button2_pdf.xml respectively.

So what i wanna do is, i want to set a pdf file against these New Activities and when I will click on btn1 or btn2 On MainActivity, I want it to display the new activity Button1PDF or Button2PDF activity which will be containing the pdfs.

I tried this online using webview and it works flawlessly. but now i want it to display offline(means complete offline)

i have done some research and i found some libraries like compile 'com.github.barteksc:android-pdf-viewer:2.0.3'

but i don't know how to use it. hope someone can clear my doubts. thanks.

1 Answers1

0

You will need to download the files first and then display them to the user using that library. Read this question on how to download file from internet

karandeep singh
  • 2,294
  • 1
  • 15
  • 22