I have made recylerview and when clicked in different list i want to load html
and also add progressbar
. I have made the layout with webview
and progressbar
and also followed as of this and many other.
this is the activity where recyclerView is shown and i want to load different html when clicked in different row of lists of recyclerView:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_abhyas);
RecyclerView recyclerView = findViewById(R.id.rv_list);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(layoutManager);
// i want to load different html when clicked these different list; and i have trackced these position in onNoteClick below:
ArrayList<Rv> rvList = new ArrayList<>();
rvList.add(new Rv(R.mipmap.blue, "१", "जन्मभूमि"));
rvList.add(new Rv(R.mipmap.green, "२", "सन्तुष्टि"));
rvList.add(new Rv(R.mipmap.orange, "३", "सन्दुक रुइत"));
rvList.add(new Rv(R.mipmap.purple, "४", "थाङ्का"));
RvAdapter adapter = new RvAdapter(rvList, this);
recyclerView.setAdapter(adapter);
}
@Override
public void onNoteCLick(int position) {
WebView webView = findViewById(R.id.webView);
if (position == 0){
// i want to load here "html"
}
if (position == 1) {
//i want to load here html2
}
}
}
and this is layout "webview.xml" which i created to load html with progressbar:
<?xml version="1.0" encoding="utf-8"?>
<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=".MainActivity">
<ProgressBar
android:id="@+id/progressBar"
android:max="3"
android:progress="100"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true" />
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_below="@+id/progressBar"
/>
</RelativeLayout>