0

I have implemented a webView within a recyclerView using Firebase as my database, but the problem is that the complete webPage is not visible, I cant scroll the web page up and down for the content and its stuck, I guess it is because of RecyclerView, please help so that I can scroll the page.

I am using Android Studio

webView class file:

  @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview_page);
        webVieRes = (RecyclerView) findViewById(R.id.resycleWeb);
        mdataRef = FirebaseDatabase.getInstance().getReference().child("weber");
    }


    @Override
    public void onStart() {
        super.onStart();
        FirebaseRecyclerAdapter<post2web,post2webViewHolder> firebaseRecyclerAdapte = new FirebaseRecyclerAdapter<post2web,post2webViewHolder>(

                post2web.class,
                R.layout.web_card,
                post2webViewHolder.class,
                mdataRef
        ) {
            @Override
            protected void populateViewHolder(post2webViewHolder viewHolder, post2web model, int position) {
                viewHolder.setWebViewPost(model.getWebViewPost());
            }
        };
        webVieRes.setAdapter(firebaseRecyclerAdapte);
    }

    public static class post2webViewHolder extends RecyclerView.ViewHolder {

        View mVie;

        public post2webViewHolder(View itemView) {
            super(itemView);
            mVie = itemView;
        }

        public void setWebViewPost(String webViewPost) {
            WebView post_web = (WebView) mVie.findViewById(R.id.webView_news);
            post_web.loadUrl(webViewPost);
            post_web.setWebViewClient(new WebViewClient());
        }
    }

RecyclerView xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layoutManager="android.support.v7.widget.LinearLayoutManager"
        android:id="@+id/resycleWeb"/>

</LinearLayout>
Rohit B
  • 165
  • 2
  • 26
  • 1
    why are you using Webview in recyclerview??? – Divyesh Patel Sep 02 '17 at 09:49
  • @DivyeshPatel can i use viewHoilder without extending RecyclerView? – Rohit B Sep 02 '17 at 09:51
  • no, but you can use Webview without recyclerview or viewholder – Divyesh Patel Sep 02 '17 at 09:51
  • but i want to fetch the webpage data through firebase database, and i guess for that i have to use it, is there any alternative to that? – Rohit B Sep 02 '17 at 09:53
  • you are getting only URL from firebase, for that u can use simple get method to get your URLs – Divyesh Patel Sep 02 '17 at 09:57
  • can you please show me with a code snippet, i was trying this earlier and did not succeeded with it. – Rohit B Sep 02 '17 at 09:58
  • https://stackoverflow.com/a/39800981/6756514 – Divyesh Patel Sep 02 '17 at 10:00
  • @DivyeshPatel here should i use webView on the place of phone query? – Rohit B Sep 02 '17 at 10:06
  • in answer: user = singleSnapshot.getValue(User.class); you get URL in 'user' parameter. then just load that url in Webview. check https://www.androidhive.info/2016/12/android-working-with-webview-building-a-simple-in-app-browser/ – Divyesh Patel Sep 02 '17 at 10:14
  • @DivyeshPatel the link you shared of androidhive is using the static method for getting url i want a dynamic one where i can change the URL later onwards and also how will i get data snapshot method in my case can you please edit the code and show in answer. – Rohit B Sep 02 '17 at 10:27
  • get url from first answer and load it using second answer. android hive show u how to setup webview – Divyesh Patel Sep 02 '17 at 10:29
  • @DivyeshPatel sir i am going to update my code above can you please tell me what to do next in it, i will be very thankful to you – Rohit B Sep 02 '17 at 10:33

0 Answers0