我一直在兜圈子,试图做一些看起来很基本的事情。我有一个DialogFragment接受用户输入的 a ,然后在提交时刷新 aListView中的 a Fragment,它是 a 的一部分ViewPager。  
我有一切工作除了Fragment不ListView刷新本身。这有点令人困惑,因为它确实刷新了数据,但我必须滑动几个视图,然后再返回查看更新的数据。
在做了一些研究之后,我应该使用getItemPositionandnotifyDataSetChanged并且ViewPager它应该可以工作。问题是调用notifyDataSetChanged会Recursive entry to executePendingTransactions引发异常:
主要活动
public class Main extends SherlockFragmentActivity implements MyListFragment.OnRefreshAdapterListener, DialogConfirmation.OnRefreshKeywordsListener //Updated Code
{
    private static List<Fragment> fragments;
    @Override
    public void onCreate(final Bundle icicle)
    {    
        setContentView(R.layout.main);
    }
    @Override
    public void onResume()
    { 
        mViewPager = (ViewPager)findViewById(R.id.viewpager);
        fragments = new ArrayList<Fragment>();
        fragments.add(new MyListFragment()); //fragment with the ListView
        fragments.add(MyDetailFragment.newInstance(0));
        fragments.add(MyDetailFragment.newInstance(1));
        fragments.add(MyDetailFragment.newInstance(2));
        mMyFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager());
        mViewPager.setAdapter(mMyFragmentPagerAdapter);
    }
    private static class MyFragmentPagerAdapter extends FragmentStatePagerAdapter  {  
        public MyFragmentPagerAdapter(FragmentManager fm) {  
             super(fm);  
        }  
        @Override  
        public Fragment getItem(int index) {
            return fragments.get(index);
        }  
        @Override
        public int getCount() {  
             return 4;  
        }
        @Override
        public int getItemPosition(Object object) {
            return POSITION_NONE;
        }
   }
    @Override
    public void onRefreshAdapterListener() {
        this.mMyFragmentPagerAdapter.notifyDataSetChanged();
    }
    //Updated Code
    @Override
    public void onRefreshTextListener() {
        MyListFragment tf = (MyListFragment)getSupportFragmentManager().findFragmentById(R.id.fragmentText);
        if (tf == null)
            tf = (MyListFragment)this.fragments.get(0);
            tf.RefreshText();       
    }
}
列表片段
public class MyListFragment extends SherlockListFragment
{
    OnRefreshAdapterListener mRefreshAdapter;
    @Override
    public void onActivityCreated(Bundle savedState) {
        adapter = new CustomAdapter();
        /*code to add items to adapter */
        this.setListAdapter(adapter);
        adapter.notifyDataSetChanged();
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        if (getArguments() != null && getArguments().getString("text").length() > 0)
        {
            SaveText(getArguments().getString("text"));
            this.mRefreshAdapter.onRefreshAdapterListener(); //this line causes a "java.lang.IllegalStateException: Recursive entry to executePendingTransactions" exception
        }
        return inflater.inflate(R.layout.listing, container, false);
    }
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        mRefreshAdapter = (OnRefreshAdapterListener)activity;
    }
    public interface OnRefreshAdapterListener {
        public void onRefreshAdapterListener();
    }
    @Override
    public void onDialogTextAdd(final String text) {
    }   
}
对话片段
public class DialogTextAdd extends DialogFragment implements OnEditorActionListener {
    private EditText mText;
    OnRefreshTextListener mTextKeywords; //Updated Code
    public interface DialogTextAddListener {
        void onDialogTextAdd(final String inputText);
    }
    public DialogTextAdd() {
        // Empty constructor required for DialogFragment
    }
    //Updated Code
    @Override
    public void onAttach(Activity act) {
        super.onAttach(act);
        mTextKeywords = (OnRefreshTextListener)act;
    }
    @Override
    public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
        final View view = inflater.inflate(R.layout.dialog_edit, container);
        mText = (EditText)view.findViewById(R.id.text_add);
        getDialog().setTitle("Add Text");
        // Show soft keyboard automatically
        mText.requestFocus();
        getDialog().getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
        mText.setOnEditorActionListener(this);
        return view;
    }
    @Override
    public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) {
        if (EditorInfo.IME_ACTION_DONE == actionId) {
            MyListFragment mf = new MyListFragment();
            Bundle args = new Bundle();
            args.putString("text", mText.getText().toString());
            mf.setArguments(args);
            //this seems to be intefering with the notifyDataSetChanged in the listing fragment
            getActivity().getSupportFragmentManager().beginTransaction().add(mf, "my_fragment").commit();
            mTextKeywords.onRefreshTextListener(); //Updated Code
            this.dismiss();
            return true;
        }
        return false;
    }
}