The Android operating system itself is a huge open-source software warehouse. Familiar with it, you can understand the design framework of the Android system and obtain efficient application programming methods. The source code analyzed in this article comes from Google's official AOSP source code 4.0.1 _ r1, And the Android version of the mobile phone is CM 4.2.2. For Android system analysis, the operating system version of the mobile phone and the source code version are not significantly different, but if you need to install the changes in the source code to the mobile phone, the most difficult way to solve the problem is to make sure that the system version in the mobile phone is exactly the same as the source code version.
After confirming the registration of the text message app and the main Activity, you can use the software to search for the app (everything is used here) determine that the SMS app is in the source code packages \ apps \ Mms \ src \ com \ android \ mms \ ui, And the startup activity of the SMS app is the ConversationList inherited from ListActivity.
1) Construction of ActionBar
In the onCreateOptionsMenu function, load the menu project by importing conversation_list_menu.
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/action_compose_new"="@string/new_message"="@drawable/ic_menu_msg_compose_holo_dark"="always|withText" /> <item android:id="@+id/search"="@string/menu_search"="@drawable/ic_menu_search_holo_dark"="ifRoom|collapseActionView"="android.widget.SearchView" /> <item android:id="@+id/action_settings"="@string/menu_preferences"="@android:drawable/ic_menu_preferences" /> <item android:id="@+id/action_delete_all"="@string/menu_delete_all"="@drawable/ic_menu_trash_holo_dark" /> <item android:id="@+id/action_debug_dump"="@string/menu_debug_dump" /></menu>
The setupActionBar () in the oncreate function is used to set the view of the Actionbar, and the number of unread messages can be displayed, but the corresponding view is not displayed on the CM mobile phone.
== (ViewGroup)LayoutInflater.from(|=
2) listview Construction
In oncreate (), set the properties of listview. setOnCreateContextMenuListener sets ContextMenu. With this option, after you click the listview column, call MENU_VIEW in the onContextItemSelected function: {openThread (threadId); break;
MQueryHandler = View emptyView =
InitListAdapter ();
Initialization of listview. The initListAdapter () in the oncreate function is as follows:
= ConversationListAdapter(,