How to implement a search field for reading inside a PDF?

0

I need to implement a search tool that can locate words within a pdf that is in PdfView. The APP I am creating is a tool where you have legislations in pdf.

I was able to implement the search tool (a magnifying glass that appears in the menu), but I can not get it to read the pdf file and display the searched word.

The code looks like this:

public class AnexoIAActivity extends AppCompatActivity
        implements SearchView.OnQueryTextListener{

    PDFView pdfView;

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

        pdfView = (PDFView) findViewById(R.id.pdfView);
        pdfView.fromAsset("Anexo I.pdf").load();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_search, menu);

        MenuItem searchItem = menu.findItem(R.id.search);
        SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
        searchView.setOnQueryTextListener(this);

        return true;
    }

    @Override
    public boolean onQueryTextSubmit(String query) {
        // User pressed the search button
        return false;
    }

    @Override
    public boolean onQueryTextChange(String newText) {
        // User changed the text
        return false;
    }
}

The SearchView menu is this:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android "
    xmlns:app="http://schemas.android.com/apk/res-auto ">
    <item android:id="@+id/search"
        android:title="@string/hint_search"
        android:icon="@android:drawable/ic_menu_search"
        app:showAsAction="collapseActionView|ifRoom"
        app:actionViewClass="android.support.v7.widget.SearchView" />
</menu>

What should I do to have my APP read inside the application by providing the information it queried?

    
asked by anonymous 09.04.2018 / 14:26

0 answers