How to refresh RecyclerView after update using Dialog from Adapter - java

I have apps where the requirement is update & delete the item of RecyclerView using dialog. The dialog will open after click the popup menu
I create the dialog function on Adapter class in onBindViewHolder. The function successfully update and delete the data on server. How do I refresh the RecyclerView after it?
Adapter.java
holder.cBtnMore.setOnClickListener(v -> {
PopupMenu popupMenu = new PopupMenu(v.getContext(), holder.cBtnMore);
popupMenu.getMenuInflater().inflate(R.menu.more_menu, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(menuItem -> {
if (menuItem.getItemId() == R.id.menu_update) {
final Dialog dialog = new Dialog(v.getContext());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_update);
dialog.getWindow().setLayout(Cons.widthScreen, Cons.heightScreen);
// Declaration & Set Text
...
btnUpdate.setOnClickListener(unused -> {
updateBarang(
v.getContext(),
id,
etNama.getText().toString(),
etAlamat.getText().toString(),
etNoPenjual.getText().toString(),
etKodeBarang.getText().toString(),
etJumlahPenjualan.getText().toString(),
etHargaSatuan.getText().toString(),
etDiskon.getText().toString(),
etTotalHarga.getText().toString()
);
});
btnCancel.setOnClickListener(unused -> {
dialog.dismiss();
});
dialog.show();
} else if (menuItem.getItemId() == R.id.menu_delete) {
Toast.makeText(v.getContext(), "Delete", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(v.getContext(), "Error", Toast.LENGTH_SHORT).show();
}
return true;
});
popupMenu.show();
});
MainActivity.java
public class MainActivity extends AppCompatActivity {
FloatingActionButton fabAdd;
RecyclerView rvBarang;
ApiInterface apiInterface;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
apiInterface = ApiConnection.Connection().create(ApiInterface.class);
...
rvBarang.setLayoutManager(new LinearLayoutManager(this));
}
#Override
protected void onResume() {
Call<List<Barang>> tampilBarang = apiInterface.listBarang();
tampilBarang.enqueue(new Callback<List<Barang>>() {
#Override
public void onResponse(Call<List<Barang>> call, Response<List<Barang>> response) {
ArrayList<Barang> barangArrayList = (ArrayList<Barang>) response.body();
BarangAdapter barangAdapter = new BarangAdapter(barangArrayList);
rvBarang.setAdapter(barangAdapter);
}
#Override
public void onFailure(Call<List<Barang>> call, Throwable t) {
// TODO
}
});
super.onResume();
}
}

If you want to update your recyclerview then you have to update your data source of adapter means list data which you are using in adapter to show and after that you need to notify adapter to refresh
To update recyclerview after delete , add below method in your adapter class
public void deleteItem(int position){
sourceList.removeAt(position); // updating source
notifyItemRemoved(position); // notify adapter to refresh
}
To refresh recyclerview after update , you must have position along with updated object so add below method also in adapter class
public void updateData(int position, Barang updatedObject){
sourceList.set(position,updatedObject); // updating source
notifyDataSetChanged(); // notify adapter to refresh
}
after adding above methods , you can just call it to refresh

Related

How to getItemCount() when using FirestoreRecyclerAdapter because it always return 0?

I'm currently building a booking application for laundry's machine. I need to get the item count and if the count is zero it will show the dialog box which told user that there is no data in the system.
The Activity code:
public class DobbySelection2 extends AppCompatActivity {
String local;
private Dialog dialog;
private FirebaseFirestore db = FirebaseFirestore.getInstance();
private DobbyAdapter adapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dobby_selection2);
dialog = new Dialog(this);
dialog.setContentView(R.layout.custom_dialog2);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
dialog.getWindow().setBackgroundDrawable(getDrawable(R.drawable.custom_dialogbackground));
}
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
dialog.setCancelable(false); //Optional
dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; //Setting the animations to dialog
Button Yes = dialog.findViewById(R.id.btn_yes);
Yes.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(DobbySelection2.this, MainActivity.class );
dialog.dismiss();
startActivity(intent);
}
});
setUpRecyclerView();
}
private void setUpRecyclerView(){
Intent i = getIntent();
local = i.getStringExtra("PLACE");
if (local == null){
local = "Selangor";
}
CollectionReference dobbyRef = db.collection("locality")
.document(local)
.collection("Dobby");
Query query = dobbyRef.orderBy("name", Query.Direction.DESCENDING);
FirestoreRecyclerOptions<Dobby> options = new FirestoreRecyclerOptions.Builder<Dobby>()
.setQuery(query, Dobby.class)
.build();
adapter = new DobbyAdapter(options);
RecyclerView recyclerView = findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);
//recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setLayoutManager(new CustomLinearLayoutManager(this));
recyclerView.setAdapter(adapter);
if(adapter.getItemCount() == 0){
dialog.show();
}
adapter.setOnItemClickListener(new DobbyAdapter.OnItemClickListener() {
#Override
public void onItemClick(DocumentSnapshot documentSnapshot, int position) {
Dobby dobby = documentSnapshot.toObject(Dobby.class);
String id = documentSnapshot.getId();
Toast.makeText(DobbySelection2.this, "ID : " + id, Toast.LENGTH_SHORT).show();
Intent intent = new Intent(DobbySelection2.this, Booking2.class);
intent.putExtra("PLACE", local);
intent.putExtra("ID", id);
startActivity(intent);
}
});
}
#Override
protected void onStart() {
super.onStart();
adapter.startListening();
}
#Override
protected void onStop() {
super.onStop();
adapter.stopListening();
}
}
Adapter code:
public class DobbyAdapter extends FirestoreRecyclerAdapter<Dobby, DobbyAdapter.DobbyHolder>{
private OnItemClickListener listener;
/**
* Create a new RecyclerView adapter that listens to a Firestore Query. See {#link
* FirestoreRecyclerOptions} for configuration options.
*
* #param options
*/
public DobbyAdapter(#NonNull FirestoreRecyclerOptions<Dobby> options) {
super(options);
}
#Override
protected void onBindViewHolder(#NonNull DobbyHolder holder, int position, #NonNull Dobby model) {
holder.textViewName.setText(model.getName());
holder.textViewAddress.setText(model.getAddress());
holder.textViewDistance.setText(model.getDistance());
}
#NonNull
#Override
public DobbyHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.itemdobby, parent, false);
return new DobbyHolder(v);
}
class DobbyHolder extends RecyclerView.ViewHolder{
TextView textViewName;
TextView textViewAddress;
TextView textViewDistance;
public DobbyHolder(#NonNull View itemView) {
super(itemView);
textViewName = itemView.findViewById(R.id.nameDobby);
textViewAddress = itemView.findViewById(R.id.addressDobby);
textViewDistance = itemView.findViewById(R.id.distanceDobby);
itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
int position = getAdapterPosition();
if(position != RecyclerView.NO_POSITION && listener != null){
listener.onItemClick(getSnapshots().getSnapshot(position), position);
}
}
});
}
}
public interface OnItemClickListener {
void onItemClick(DocumentSnapshot documentSnapshot, int position);
}
public void setOnItemClickListener(OnItemClickListener listener){
this.listener = listener;
}
}
But the dialog box always pop up indicating that the count is zero even though there is data inside of the recycler view. How can I fix this?
My guess is that the dialog you're talking about comes from here:
if(adapter.getItemCount() == 0){
dialog.show();
}
If so, it makes sense that it shows up as this code runs before any data has been loaded.
Data is loaded from Firestore (and most modern cloud APIs) asynchronously, and this changes the order in which code executes. It's easiest to see this if you set breakpoint on the if line above, on adapter.startListening(); and on the first line inside your onBindViewHolder.
If you now run the code in the debugger, you'll see that it:
First hits the if(adapter.getItemCount() == 0){ line
Then adapter.startListening()`
Then gets to onBindViewHolder
So now it hopefully makes sense why your code always show the dialog: no data has been loaded yet at that point.
The solution for this is always the same: you need to make sure that the code that needs the data runs after the data has been loaded. Since you're using the FirestoreRecyclerAdapter from FirebaseUI, you can do this inside its onDataChanged method that signals that a complete snapshot was loaded (regardless of whether there was any data in that snapshot) and is shown in the documentation on data and error events.
So if you move your if check into a onDataChanged method in your DobbyAdapter, it will get called whenever the adapter has loaded a complete snapshot, and it will show the dialog when there are no items.

Sending the path of clicked item in recyclerview to a dialog activity

I have a RecyclerView, long click listener on any item will open delete dialog, the delete dialog contain two buttons, delete and cancel, when clicking on delete a document in Firestore should be deleted.
Now, how can I get the path of clicked item and send it to the delete dialog?
I can't use (intent) in dialog activity!
Note: I know there is other way to make a dialog but I faced the same problem..
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_std_in_this_class);
Intent intent = getIntent();
final String MyG = intent.getStringExtra(EXTRA_MYG);
query = db.collection("aaa").document("bbb").collection("ddd")
.document(UserId).collection(MyG).whereEqualTo("f",1);
FirestoreRecyclerOptions <infoOfMyStd> options = new
FirestoreRecyclerOptions.Builder<infoOfMyStd>()
.setQuery(query, infoOfMyStd.class)
.build();
mystdsAdapter = new MyStdsAdapter(options);
mystdsAdapter.setOnItemLongClickListener(new MyStdsAdapter.OnItemLongClickListener() {
#Override
public boolean onItemLongClicked(int position, DocumentSnapshot documentSnapshot) {
infoOfMyStd infoofmystd = documentSnapshot.toObject(infoOfMyStd.class);
String path = documentSnapshot.getReference().getPath();
Intent intent = new Intent(MyStdInThisClass.this, DeleteDialog.class);
intent.putExtra(EXTRA_STD_PATH, path);
startActivity(intent);
return true;
}
});
RecyclerView recyclerView = findViewById(R.id.my_stds_recyclerview);
recyclerView.setHasFixedSize(true); //for performane reasons
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(mystdsAdapter);
mystdsAdapter.startListening();
////
}
And ViewHolder in the the adapter:
cardView.setOnLongClickListener(new View.OnLongClickListener() {
#Override
public boolean onLongClick(View v) {
DeleteDialog dialog = new DeleteDialog(v.getContext());
dialog.show();
return true;
}
});
Also in the Adapter:
public interface OnItemLongClickListener {
public boolean onItemLongClicked(int position, DocumentSnapshot documentSnapshot);
}
public void setOnItemLongClickListener(OnItemLongClickListener Llistener){
this.Llistener = Llistener;
}
Appreciate your help..

How to display contents retrieved from Firebase Realtime Database on a ListView as the apps loads

I'm trying to display records saved in Firebase Database to the user in a ListView as The Application loads but it's not working.
The problem is that when the app loads for the first time the contents are not added to the ListView.
As I'm testing the app I noticed that the contents are not displayed as I open the app for the first time but only if I close the app by pressing the back button and then reopen it.
I add this method: adapter.notifyDataSetChanged(); to the onStart() as suggested by some guy but it didn't work.
This is the method that fetches the data:
private void fetchData() {
if (FirebaseDatabase.getInstance() != null) {
FirebaseDatabase.getInstance().goOffline();
}
FirebaseDatabase.getInstance().goOnline();
Query query = FirebaseDatabase.getInstance().getReference().child("User");
FirebaseRecyclerOptions<User> options =
new FirebaseRecyclerOptions.Builder<User>()
.setQuery(query, new SnapshotParser<User>() {
#NonNull
#Override
public User parseSnapshot(#NonNull DataSnapshot snapshot) {
s = snapshot.getChildrenCount();
Toast.makeText(getApplicationContext(), Long.toString(s), Toast.LENGTH_SHORT).show();
return new User(snapshot.child("fullName").getValue().toString(),
snapshot.child("userId").getValue().toString());
}
})
.build();
adapter = new FirebaseRecyclerAdapter<User, MyViewHolder>(options) {
#Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.database_contents, parent, false);
return new MyViewHolder(view);
}
#Override
protected void onBindViewHolder(#NonNull MyViewHolder myViewHolder, final int i,
#NonNull User user) {
myViewHolder.setTxtFullName(user.getFullName());
myViewHolder.setTxtUserId(user.getUserId());
myViewHolder.root.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), String.valueOf(i), Toast.LENGTH_SHORT).show();
}
});
}
};
}
and this is where I made the call:
#Override
protected void onStart() {
super.onStart();
fetchData();
recyclerView.setAdapter(adapter);
adapter.startListening();
adapter.notifyDataSetChanged();
}
I also tried calling the fetchData() method in onCreate.
I will like the contents to be displayed in the ListView as the App loads for the first time. Thanks in advance
here is simple way to get firebase data in listview as below..
final DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference().child("Contacts");
mDatabase.child(user_id).addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshott) {
list = new ArrayList<>();
for (DataSnapshot ds : dataSnapshott.getChildren()){
final String key_idd = ds.getKey();
Listdata listdata = new Listdata();
String name=ds.child("name").getValue(String.class);
listdata.setName(name);
listdata.setKey_id(key_idd);
list.add(listdata);
}
recycler = new RecyclerviewAdapter(MyContactActivity.this, list);
recyclerview.setAdapter(recycler);
}
#Override
public void onCancelled(DatabaseError error) {
// Failed to read value
Log.e("Error", "Failed to read user", error.toException());
}
});
Firebase uses listener for reading data so you see your result on your second opening. You should use interface for data reading.

How to dynamically create buttons from Json string

I parsed JSON data from URL into a list and now I want to create buttons with every item of the list, but I can't figured out how to do this. I'm not sure if the list is the best idea, but I this was the solution I found online.
public class SecondActivity extends AppCompatActivity {
private String TAG = SecondActivity.class.getSimpleName();
private ProgressDialog pDialog;
private ListView lv;
private static String url = "https://ggysqqcz.p51.rt3.io/available-remotes/TV";
ArrayList<HashMap<String, String>> contactList;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
contactList = new ArrayList<>();
lv = (ListView) findViewById(R.id.list);
new GetContacts().execute();
}
private class GetContacts extends AsyncTask<Void, Void, Void> {
#Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(SecondActivity.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
}
#Override
protected Void doInBackground(Void... arg0) {
HttpHandler sh = new HttpHandler();
// Making a request to url and getting response
String jsonStr = sh.makeServiceCall(url);
Log.e(TAG, "Response from url: " + jsonStr);
if (jsonStr != null) {
try {
JSONObject jsonObj = new JSONObject(jsonStr);
// Getting JSON Array node
JSONArray remotes = jsonObj.getJSONArray("remotes");
// looping through All Contacts
for (int i = 0; i < remotes.length(); i++) {
JSONObject c = remotes.getJSONObject(i);
String id = c.getString("id");
HashMap<String, String> contact = new HashMap<>();
contact.put("id", id);
contactList.add(contact);
}
} catch (final JSONException e) {
Log.e(TAG, "Json parsing error: " + e.getMessage());
runOnUiThread(new Runnable() {
#Override
public void run() {
Toast.makeText(getApplicationContext(),
"Json parsing error: " + e.getMessage(),
Toast.LENGTH_LONG)
.show();
}
});
}
} else {
Log.e(TAG, "Couldn't get json from server.");
runOnUiThread(new Runnable() {
#Override
public void run() {
Toast.makeText(getApplicationContext(),
"Couldn't get json from server. Check LogCat for possible errors!",
Toast.LENGTH_LONG)
.show();
}
});
}
return null;
}
#Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
ListAdapter adapter = new SimpleAdapter(
SecondActivity.this, contactList,
R.layout.list_item, new String[]{"id"}, new int[]{button1});
lv.setAdapter(adapter);
}
}
public void onClickButton1(View view) {
startActivity(new Intent(getApplicationContext(), ThirdActivity.class));
}
}
This shows all the buttons, but obviously they all do the same thing when clicked because I have only button1. How can I make all the buttons do different activities?
I would like to suggest creating a custom adapter for your ListView which will have an onClick function for your button and based on the position of that item in your ListView, you can implement different actions in your onClick function. Hence I would like to suggest an adapter like the following.
public class ListAdapter extends ArrayAdapter<Item> {
private int resourceLayout;
private Context mContext;
private ArrayList<Contact> contacts;
public ListAdapter(Context context, int resource, ArrayList<Contact> contacts) {
super(context, resource, items);
this.resourceLayout = resource;
this.mContext = context;
this.contacts = contacts;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi;
vi = LayoutInflater.from(mContext);
v = vi.inflate(resourceLayout, null);
}
Item p = getItem(position);
if (p != null) {
Button btn = (TextView) v.findViewById(R.id.button1);
if (btn != null) {
btn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if(position == 1) implementSomethingFor1();
else if (position == 2) implementSomethingFor2();
// ... Define the other implementations
}
});
}
}
return v;
}
}
And then use the adapter like the following.
ListView lv = (ListView) findViewById(R.id.list);
ListAdapter customAdapter = new ListAdapter(this, R.layout.list_item, contactList);
lv.setAdapter(customAdapter);
Please note that this is not an exact implementation. You should modify your custom adapter so that it serves your purpose.
try
lv.setonitemclicklisnter, this will create a method which will allow you to click on each and every item, you can write for example A Toast message inside this method so when you click on an item a Toast message will pop up.
You have several options:
Check the view parameter to determine what to do. You can use getTag() and setTag() to provide custom data on each button.
Create a custom adapter by extending SimpleAdapter. Override createView() and bindView() in order to provide custom behavior for each button, such as adding a different OnClickListener object to each button
Set the OnItemClickListener for the ListView. This provides a parameter for which position in the list view was clicked. You can use that to determine what to do or what data to pass to the new activity. You will likely want to use getItem() from your adapter to get the data for the current row.

PullToRefresh in Fragment

I have list which need to refresh and I use PullToRefresh. I used to work with Activiti, but now I need to rewrite everything in the fragment. When I used the Activiti everything worked fine, but now I have found a mistake when I copied everything I used the same methods and logic, but an error has occurred nullpointerexception. This is my code of Fragment:
private PullToRefreshListView mPullRefreshListView;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_vk, container, false);
Map<String, String> networkDetails = getConnectionDetails();
if (networkDetails.isEmpty()) {
Toast.makeText(getActivity().getApplicationContext(),
"Нет интернет подключения!", Toast.LENGTH_LONG).show();
}
getActivity().getActionBar().setDisplayShowTitleEnabled(false);
/** Create an array adapter to populate dropdownlist */
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
getActivity().getBaseContext(),
android.R.layout.simple_spinner_dropdown_item, actions);
/** Enabling dropdown list navigation for the action bar */
getActivity().getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
/** Defining Navigation listener */
ActionBar.OnNavigationListener navigationListener = new OnNavigationListener() {
#Override
public boolean onNavigationItemSelected(int itemPosition,
long itemId) {
switch (itemPosition) {
case 1:
Intent intent1 = new Intent(getActivity().getApplicationContext(),
KfuNews.class);
getActivity().finish();
startActivity(intent1);
break;
}
return false;
}
};
/**
* Setting dropdown items and item navigation listener for the actionbar
*/
getActivity().getActionBar().setListNavigationCallbacks(adapter, navigationListener);
boolean firstrun = getActivity().getSharedPreferences("PREFERENCE", getActivity().MODE_PRIVATE)
.getBoolean("firstrun", true);
// Set a listener to be invoked when the list should be refreshed.
mPullRefreshListView
.setOnRefreshListener(new OnRefreshListener<ListView>() {
#Override
public void onRefresh(
PullToRefreshBase<ListView> refreshView) {
String label = DateUtils.formatDateTime(
getActivity().getApplicationContext(),
System.currentTimeMillis(),
DateUtils.FORMAT_SHOW_TIME
| DateUtils.FORMAT_SHOW_DATE
| DateUtils.FORMAT_ABBREV_ALL);
// Update the LastUpdatedLabel
refreshView.getLoadingLayoutProxy()
.setLastUpdatedLabel(label);
// Do work to refresh the list here.
new GetDataTask().execute();
}
});
// Add an end-of-list listener
mPullRefreshListView
.setOnLastItemVisibleListener(new OnLastItemVisibleListener() {
#Override
public void onLastItemVisible() {
Toast.makeText(getActivity().getApplicationContext(), "End of List!",
Toast.LENGTH_SHORT).show();
}
});
sp11 = getActivity().getSharedPreferences("VK", 0);
editor1 = sp11.edit();
account.restore(getActivity());
if ((firstrun) || (account.access_token == null)) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("Авторизация")
.setMessage(
"для просмотра новостей необходимо авторизоваться.")
.setCancelable(false)
.setPositiveButton("Авторизоваться",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
editor1.putInt("isVk", 1).commit();
editor1.apply();
startLoginActivity();
}
})
.setNegativeButton("Отмена",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
dialog.cancel();
editor1.putInt("isVk", 0).commit();
editor1.apply();
Intent intent = new Intent(
getActivity().getApplicationContext(),
KfuNews.class);
getActivity().finish();
startActivity(intent);
}
});
AlertDialog alert = builder.create();
alert.show();
// Save the state
getActivity().getSharedPreferences("PREFERENCE", getActivity().MODE_PRIVATE).edit()
.putBoolean("firstrun", false).commit();
}
if (account.access_token != null) {
api = new Api(account.access_token, Constants.API_ID);
}
Log.d("isChange", isChangedStat + "");
getWall();
return view;
}
And I have problem at this line:
mPullRefreshListView
.setOnRefreshListener(new OnRefreshListener<ListView>() {
There I have nullpointerexception, and I do not have much time to solve the problem, please help with.
You are not initializing your mPullRefreshListView variable thus the nullpointerexception. Based on your code you are missing this line:
mPullRefreshListView = (PullToRefreshListView) view .findViewById(R.id.mPullRefreshListView);
initiate the listview in fragment and add listener to refreshlayout to this listview.

Categories