服务器上有一些更新数据库的同步过程,我想在单击对话关闭时刷新父活动以获取视图中的同步值。
我有三个片段FragmentA.java
-FragmentB.java
和ragmentC.java
在FragmentA.java
,我有公共接口OnEntrySelectedListener
,它有方法getDialog()
和其他片段类FragmentB.java
实现这个接口并有getDialog()
方法的定义。
片段A.java
class FragmentA extends Fragment
{
public interface OnEntrySelectedListener
{
getDialog();
}
}
片段B.java
class FragmentB extends FragmentActivity implements FragmentA.OnEntrySelectedListener
{
@Override
public void getDialog(Bundle bundle) {
FragmentC cf = new FragmentC();
cf.setArguments(bundle);
cf.show(getSupportFragmentManager(), "dialog");
}
}
片段C.java
class FragmentC extends DialogFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
//some code here
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
view = inflater.inflate(R.layout.shared,container, false);
view.findViewById(R.id.button1).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0)
{
getDialog().dismiss(); //Here after dismiss, I want to refresh FragmentA
}
});
return view;
}
现在我想FragmentA
刷新FragmentC
.