How to use swipe left gesture to read a full news article in Inshorts news app | Inshorts News App Clone PART 3 | Android Studio | Firebase


Part 1: add a page change listener

  • For each news position, we need to store its position in a variable and for direction, we take two float variables.
int newposition;float x1,x2;
  • After then add page change listener in where we set our data in the adapter class
  • then set on touch listener in the vertical ViewPager
  • here we will set the touch to the left i.e. when we swipe left a new activity will open, where we set our newsLink.

Part 2: Details Activity

  • Now, create a new activity(/package/activities/NewActivity) and add a WebView for our newsLink.
  • Create a WebView in the new XML file
<WebView    android:layout_width="match_parent"    android:layout_height="match_parent"    android:id="@+id/webview"/>
  • And, In the new java file gets the data from intent and shows it in the webView.

Part 3: Give Permissions

  • before running the app gives the INTERNET and ACCESS_NETWORK_STATE permission



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Golap Gunjan Barman

Golap Gunjan Barman

Hi everyone, myself Golap an Android app developer with UI/UX designer.