Questions about displaying PDFs in Android app internal fragments

Asked 2 years ago, Updated 2 years ago, 93 views

Hi, everyone. The questions I asked you before were solved, but this time There was another problem, so I asked you this question.

I want to put a pdf on the fragment on Android, but I want to use PdfRender, the official app of Android I tried to use it, but it was only supported by the above version of Lollipop. Even in the lower version, I'm looking for another way because it needs to be used.

So I tried to google some libraries and apply them The sample source was imported and used as org.androidannotations.annotations.

//main class
@EActivity(R.layout.activity_main)
@OptionsMenu(R.menu.options)
public class PDFViewActivity extends AppCompatActivity implements OnPageChangeListener, OnLoadCompleteListener {

    private static final String TAG = PDFViewActivity.class.getSimpleName();

    private final static int REQUEST_CODE = 42;

    public static final String SAMPLE_FILE = "sample.pdf";
    ...// Subsequent omissions

Even though the main class exists, the name of the activity in the manifest is in the name of the class _ (underbar) is included, and I went back in and looked at the path, and it was the final with _ (underbar) attached The declared class is inheriting the main class.

// Example
<activity
            android:name="PDFViewActivity_"
            android:label="@string/app_name" >

It doesn't look like it's hidden, but it doesn't appear in the project explorer. Below is the onCreate portion of the class with _ (underbar).

 @Override
    public void onCreate(Bundle savedInstanceState) {
        OnViewChangedNotifier previousNotifier = OnViewChangedNotifier.replaceNotifier(onViewChangedNotifier_);
        init_(savedInstanceState);
        super.onCreate(savedInstanceState);
        OnViewChangedNotifier.replaceNotifier(previousNotifier);
        setContentView(R.layout.activity_main);
    }

I've never seen a code written in this way, but when I saw it so far, I think it's shown on the screen through another processing in the class with a _ (underbar).

I made a new project and applied it in my own way, but the pdf doesn't come up properly.

If you know anything about this, or if you have a simpler example, please answer I would be grateful.

Thank you for reading the long question. It's getting really cold, so be careful not to catch a cold.

android fragment pdf

2022-09-22 11:54

1 Answers

The sample source is a feature of the code created by AndroidAnnotations. In other words, activities with _ are code generated when compiled by AndroidAnnotations.

You should always register your activity with an _ suffix in the Android Manifest.

This is because AndroidAnnotations generates a subclass for each annotated activity. It has the same package and name, plus an _ suffix.

Since the AndroidAnnotations concept is one of the purposes of reducing the boilerplate code to keep the code simple, it seems that there is no need to study the principle around the activity with _. I think you just need to refer to how the PDF is printed from the source.


2022-09-22 11:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.