i have 114 items in recylerview , each item have Download button, i want when user click on download then it start downloading and after downloading button shoud be INVISIBLE, i am using button.setVisibility(View.INVISIBLLE) ,but when i close app and reopen app then again all button are visible.
Asked
Active
Viewed 30 times
0
-
Can you show what you have done already in code? maybe showing adapter of your recyclerview. – YaMiN Feb 25 '21 at 21:35
-
Yes, can you give you Email adress or whatsapp. – Aamir Mehmood Lucky Feb 26 '21 at 16:27
-
Try fixing your question, fill it with more detail like adding your code and showing how actually you tried. – YaMiN Feb 26 '21 at 16:49
-
`btndownload.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { recyclerViewClickInterface.onItemDownload(getAdapterPosition()); } });` **this is Button Click Listner ** – Aamir Mehmood Lucky Feb 27 '21 at 13:29
-
`public interface RecyclerViewClickInterface { void onItemClickOnline(int position); void onItemClickOffline(int position); void onItemDownload(int position); } ` here is interfface and ftn – Aamir Mehmood Lucky Feb 27 '21 at 13:30
-
`Button btndownload = recyclerView.getChildAt(position).findViewById(R.id.downloadid); btndownload.setVisibility(View.INVISIBLE); DataHere.getHide().set(position, true); Save();` Condition on button download function – Aamir Mehmood Lucky Feb 27 '21 at 13:34
-
`public void Save() { SharedPreferences preferences = getApplicationContext().getSharedPreferences("comesting.example.codingstars6", Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); StringBuilder builder = new StringBuilder(); for (boolean i : DataHere.getHide()) { builder.append(i ? '1' : '0'); } editor.putString("BOOLEAN_ARRAY", builder.toString()).apply(); }` SAVE FUNCTION – Aamir Mehmood Lucky Feb 27 '21 at 13:35
-
`public void Load() { SharedPreferences preferences = getApplicationContext().getSharedPreferences("comesting.example.codingstars6", Context.MODE_PRIVATE); String arrayPrefs = preferences.getString("BOOLEAN_ARRAY",null); if(!TextUtils.isEmpty(arrayPrefs)){ DataHere.getHide().clear(); for(int i = 0; i < suratE.size(); i++){ assert arrayPrefs != null; DataHere.getHide().add(arrayPrefs.charAt(i) == '1'); } } }` LOad function – Aamir Mehmood Lucky Feb 27 '21 at 13:36
-
`public class DataHere { public static ArrayList
hide = new ArrayList<>(); public static ArrayList – Aamir Mehmood Lucky Feb 27 '21 at 13:38getHide() { return hide; } public static void setHide(ArrayList hide) { DataHere.hide = hide; } }`