I am doing adapter.notifyDataSetChanged()
and listView.invalidateViews()
after I get the receive call if the condition say "blabla" gets true. But still my UI is not getting updated.
public class UserFragment extends Fragment{
public class FragmentReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if(getSetting("CurrentView","").equalsIgnoreCase("blabla")){
adapter.notifyDataSetChanged();
listView.invalidateViews(); //this is not updating the UI.
}
}
NOTE: I tried to call the same UserFragment.java
to update the changes by replacing the same fragment again but that's although updating the UI but giving exceptions- IllegalStateException: Can not perform this action after onSaveInstanceState
My rest of the code in onReceive
method -
UserFragment firstFragment = new UserFragment ();
getSupportFragmentManager().beginTransaction()
.replace(R.id.headlines_fragment, firstFragment)
.addToBackStack(null).commit(); //IllegalStateException: Can not perform this action after onSaveInstanceState
Any ideas?
try this
public class UserFragment extends Fragment{
public class FragmentReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if(getSetting("CurrentView","").equalsIgnoreCase("blabla")){
adapter.notifyDataSetChanged();
listView.invalidateViews(); //this is not updating the UI.
UserFragment.this.onCreate(savedInstanceState);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.