---
title: "How to calling a fragmnet inside its ListView Adapter?"  
description: "How to calling a fragmnet inside its ListView Adapter?"  
author: "Royce Roy"  
published: 2014-10-14  
updated: 2014-10-14  
canonical: https://www.mindstick.com/forum/2378/how-to-calling-a-fragmnet-inside-its-listview-adapter  
category: "android"  
tags: ["android", "mobile development"]  
reading_time: 3 minutes  

---

# How to calling a fragmnet inside its ListView Adapter?

I have a [Fragment](https://www.mindstick.com/forum/12894/how-to-force-recreation-of-activity-fragment-on-restore) which has a [ListView](https://www.mindstick.com/articles/12744/listview-in-android) inside it , in each [row](https://www.mindstick.com/forum/1212/this-row-already-belongs-to-this-table) of my ListView i have a [delete](https://www.mindstick.com/forum/33620/how-to-delete-record-from-list-in-mvc-using-ajax) [Button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) which works perfectly, what i need is to [refresh](https://www.mindstick.com/forum/12865/how-to-refresh-dropdownlist-but-keep-old-selected-value-json) my ListView to show the updated data. my [question](https://www.mindstick.com/blog/23175/how-to-solve-neet-question-paper-in-less-time) is how can i refresh my ListView inside its Adapter. this is my Adapter:\

```
public class BrowserBannedListViewAdapter extends BaseAdapter {Context mContext;private static List<BrowserBannedSites> listUrlForAdapter;AppSQLiteHelper db;public BrowserBannedListViewAdapter(Context c, List<BrowserBannedSites> urls) {    mContext = c;    listUrlForAdapter = urls;}public static void main(String[] args) {    // TODO Auto-generated method stub}@Overridepublic int getCount() {    // TODO Auto-generated method stub    return listUrlForAdapter.size();}@Overridepublic Object getItem(int position) {    // TODO Auto-generated method stub    return null;}@Overridepublic long getItemId(int position) {    // TODO Auto-generated method stub    return 0;}static class ViewHolder {    TextView text;    ImageView icon;}@Overridepublic View getView(final int position, View convertView, ViewGroup parent) {    ViewHolder viewHolder;    LayoutInflater li = (LayoutInflater) mContext            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);    if (convertView == null) {        convertView = li.inflate(R.layout.row_fragment_browser_url, null);        viewHolder = new ViewHolder();        viewHolder.text = (TextView) convertView                .findViewById(R.id.tv_fragment_browser_url_name);        viewHolder.icon = (ImageView) convertView                .findViewById(R.id.iv_fragment_browser_delete);        viewHolder.icon.setOnClickListener(new OnClickListener() {            @Override            public void onClick(View v) {                        db=new AppSQLiteHelper(mContext);                int tempID =listUrlForAdapter.get(position).get_Id();                db.deleteBannedSites(tempID);  //******************** here is where i want to refresh my listview            }        });        convertView.setTag(viewHolder);    } else {        viewHolder = (ViewHolder) convertView.getTag();    }      viewHolder.text.setText(listUrlForAdapter.get(position).get_browserBannedSitesAddress());    return convertView;}}
```

## Replies

### Reply by Anonymous User

change first the List of your data and You can directly call notifyDataSetChanged();\

```
@Override        public void onClick(View v) {                    db=new AppSQLiteHelper(mContext);            int tempID =listUrlForAdapter.get(position).get_Id();            db.deleteBannedSites(tempID);     //******************** here is where i want to refresh my listview            notifyDataSetChanged();        }    });
```

### Reply by Anonymous User

Only deleting from database will not working. you need to delete from List too.\

```
deleteButton.setOnClickListener(new OnClickListener(){   public void onClick(View v){      .........      listUrlForAdapter.remove(position); // position is the position of the custom view in the list       notifyDataSetChanged();    }}
```


---

Original Source: https://www.mindstick.com/forum/2378/how-to-calling-a-fragmnet-inside-its-listview-adapter

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
