Public class TodolistFragment extends fragments {
Private ListTodos=new ArrayList<> (a);
//the NotificationManager NotificationManager.
SimpleAdapter adapter.
ListView ListView.
View the View;
The Button Button;
Private int uid;
Private String for the date.
@ Override
Public void onAttach (Context Context) {
Super. OnAttach (context);
Uid=((HomePage) context.) user_id,
The date=((HomePage) context). The date;
//buttonClickListener=(OnItemButtonClickListener) context;
}
@ Override
Public void onActivityCreated (Bundle savedInstanceState) {
Super. OnActivityCreated (savedInstanceState);
The button=(button) getActivity (). The findViewById (da dd_list R.i);
Button. SetOnClickListener (new View. An OnClickListener () {
@ Override
Public void onClick (View v) {
ShowDialog ();
}
});
LocalBroadcastManager broadcastManager=LocalBroadcastManager. GetInstance (getActivity ());
IntentFilter IntentFilter=new IntentFilter ();
IntentFilter. AddAction (" android. Intent. Action. CART_BROADCAST ");
BroadcastReceiver mItemViewListClickReceiver=new BroadcastReceiver () {
@ Override
Public void onReceive (Context Context, Intent Intent) {
String MSG=intent. GetStringExtra (" data ");
If (" refresh ". The equals (MSG))
The init ();
}
};
BroadcastManager. RegisterReceiver (mItemViewListClickReceiver intentFilter);
}
@ Override
Public View onCreateView (LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View=inflater. Inflate (R.l ayout. Activity_todolist_fragment, container, false);
The init ();
ListView=(listView) view. The findViewById (R.i d.l ist);
Return the view;
}
/* public interface OnItemButtonClickListener {
Void onItemViewClick (View v);
} */
@ Override
Public void onResume () {
System. Out.println (" todolist onresume!" );
super.onResume();
//init ();
}
Private void init () {
ListView=(listView) view. The findViewById (R.i d.l ist);
MySqliteDB mydb=new MySqliteDB (the getContext (), "mydb", null, 1);
SQLiteDatabase db=mydb. GetReadableDatabase ();
Cursor Cursor;
Cursor=db. Query (" todolist ", new String [] {" list_id ", "title", "total_time", "complete_time}", "user_id=" + uid, null, null, null, null);
ArrayList
CodePudding user response:
Is there a log can see,CodePudding user response:
Describe the process of clear the Activity returns to the Fragment is to refresh the fragments of data but did not break out?Please read the debug process go to take a look at your code
CodePudding user response: