I have a listView fulled from my custom ArrayAdapter. In each view there is a button. I want to change the current fragment when the button is clicked. This is my code:
its so late but here no one answered this question so.
you can invoke fragment manager in your getview method using
FragmentManager fm = ((Activity)context).getFragmentManager();
getFragmentManager() is a method of Activity class .
for example
holder.tvBuy.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
Fragment fragment;
fragment = new Buy();
((Activity)context).getFragmentManager().beginTransaction().replace(R.id.content_frame,fragment).commit();
}
}
here you need to pass your activity as context to your adapter.
hope it will help someone....