我想在下面的代码中刷新或调用 onCreateView。我有一个上下文菜单来删除一个项目,在我想用新项目刷新片段之后.. 非常感谢!
public class ItemDetailFragmentBlackBoard extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
....
return rootView;
}
/** Menu on LongClick */
@Override
public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Context Menu");
menu.add(0, v.getId(), 0, "Delete");
}
@Override
public boolean onContextItemSelected(MenuItem item) {
if(item.getTitle()=="Delete"){
String status="";
AdapterContextMenuInfo info = (AdapterContextMenuInfo)item.getMenuInfo();
int posizione = info.position;
String[] messaggioDaCancellare= S.getMessaggiInfo().get(posizione);
try{
JSONObject del =ProxyUtils.proxyCall("deleteMessage",messaggioDaCancellare[4]);
status=del.getString("status");
} catch (Exception e) {
Log.i("Eccezione", e.toString());
}
Activity activity= getActivity();
if(status.equals("OK")){
**HERE......I would like to refresh my fragment o recall onCreateView method...**
Toast.makeText(activity, "Delete avvenuta", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(activity, "Delete non riuscita", Toast.LENGTH_SHORT).show();
}
} else {return false;}
return true;
}