I would like to update or call onCreateView in the following code. I have contex menù to delete an element, and after I want to update the fragment with a new element. Thanks at all!
public class ItemDetailFragmentBlackBoard extends fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
....
return rootView;
}
}
@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;
}
source
share