I want to make a theme app and I have a home page where I am trying to show some theme As a category, and there I am using RecyclerView for each category, and my Recyclerview get data from firebase real-time database where I use one image link, one text, and one URL which I want to show in my WebView through this code
Intent intent = new Intent(v.getContext().getApplicationContext(), BrowserActivity.class);
intent.putExtra("url_E", url);
v.getContext().startActivity(intent);
but the problem is all items are fetching perfectly from firebase, and showing the correct title and image each and every item of my Recyclerview but if I click the 6 or 7 items from Recyclerview then the link was not loaded correctly, The link that is loading is not that item link, The link is being replaced with another item link and that wrong link I can find in the database from another item in the same category. ****Please Help Me
If I add a Toast.makeText(, url, Toast.LENGTH_SHORT).show(); with setOnClickListener then the correct link is showing in Toast but the load link on the webpage is wrong same!!!! -- -- ♀️♂️♂️♂️♂️
HErer is my activity : enter image description here
layout:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="end"
android:orientation="horizontal">
<ImageView
android:layout_width="17dp"
android:layout_height="17dp"
android:layout_gravity="bottom"
android:layout_marginStart="5dp"
android:layout_marginEnd="10sp"
android:src="@drawable/theme_review" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/RVModern"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_marginBottom="8dp"
android:paddingStart="10dp" />
MainFragemnt:
DataRef = FirebaseDatabase.getInstance().getReference("ThemeByStyle");
// Modern
DataRef.child("ModernTheme").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()) {
for (DataSnapshot npsnapshot : dataSnapshot.getChildren()) {
ListDataMODERN = npsnapshot.getValue(ListData.class);
listData1.add(ListDataMODERN);
}
homeAdapter = new HomeAdapter(listData1);
RVModern.setAdapter(homeAdapter);
Collections.reverse(listData1);
RVModern.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
homeAdapter.notifyDataSetChanged();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
adapter:
{
private final List<ListData> listData;
CardView ClickItem;
String url;
ImageView post_img;
TextView post_title;
Dialog OkBox;
public HomeAdapter (List<ListData> listData) {
this.listData = listData;
}
@SuppressLint("WrongConstant")
@NonNull
@Override
public HomeAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.post_body_home,parent,false);
ClickItem = view.findViewById(R.id.cardview);
OkBox = new Dialog(view.getContext());
return new HomeAdapter.ViewHolder(view);
}/**************************************************************************/
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
final ListData listdata = listData.get(position);
holder.setUrlss(listdata.getUrls());
holder.setTitle(listdata.getTitle());
holder.setImgOne(listdata.getImg1());
// url = listdata.getUrls();
}
@Override
public int getItemCount () {
return listData.size();
// return 2; }
public class ViewHolder extends RecyclerView.ViewHolder {
View vv;
public ViewHolder(View itemView) {
super(itemView);
vv = itemView;
}
public void setTitle(String title) {
post_title = vv.findViewById(R.id.post_title);
post_title.setText(title);
}
public void setImgOne(String imgone) {
post_img = vv.findViewById(R.id.imgOne);
Glide
.with(vv)
.load(imgone)
.into(post_img);
}
public void setUrlss (String setUrls) {
TextView urltxt = vv.findViewById(R.id.urltxt);
urltxt.setText(setUrls);
url = setUrls;
ClickItem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext().getApplicationContext(), BrowserActivity.class);
intent.putExtra("url_E", url);
v.getContext().startActivity(intent);
/* Okbox();
ClipboardManager clipboard = (ClipboardManager) v.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("label", setUrlXX);
clipboard.setPrimaryClip(clip);
Toast.makeText(v.getContext().getApplicationContext(), setUrlXX, Toast.LENGTH_SHORT).show();*/
}
});
}
}
private void Okbox() {
OkBox.setContentView(R.layout.ok);
Window window = OkBox.getWindow();
window.setLayout(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
window.setGravity(Gravity.TOP);
TextView t0title = OkBox.findViewById(R.id.t0title);
t0title.setText(url);
OkBox.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
OkBox.show();
}
}
HELP ME PLZ PLZ PLZ PLZ PLZ PLZ PLZ PLZ