Android mobile guard 10 -- Application Manager, android10 --

Source: Internet
Author: User

Android mobile guard 10 -- Application Manager, android10 --

1. Add different types of entries

1 class MyAdapter extends BaseAdapter {2 3 // obtain the total number of entry types in the data adapter, and change it to two types (plain text, image + text) 4 @ Override 5 public int getViewTypeCount () {6 return super. getViewTypeCount () + 1; 7} 8 9 // specify the entry type pointed to by the index, specify the entry type status code (0 (Reuse System), 1) 10 @ Override11 public int getItemViewType (int position) {12 if (position = 0 | position = mCustomerList. size () + 1) {13 // return 0, representing the status code 14 return 0; 15} else {16 // return 1, represents the image + text entry status code 17 return 1; 18} 19} 20 21 // Add two description entries 22 @ Override23 public int getCount () {24 return mCustomerList in listView. size () + mSystemList. size () + 2; 25} 26 27 @ Override28 public AppInfo getItem (int position) {29 if (position = 0 | position = mCustomerList. size () + 1) {30 return null; 31} else {32 if (position <mCustomerList. size () + 1) {33 return mCustomerList. get (position-1); 34} else {35 // return the 36 return mSystemList object corresponding to the system application. get (position-mCustomerList. size ()-2); 37} 38} 39} 40 41 @ Override42 public long getItemId (int position) {43 return position; 44} 45 46 @ Override47 public View getView (int position, View convertView, ViewGroup parent) {48 int type = getItemViewType (position); 49 50 if (type = 0) {51 // display gray plain text entries 52 ViewTitleHolder holder = null; 53 if (convertView = null) {54 convertView = View. inflate (getApplicationContext (), R. layout. listview_app_item_title, null); 55 holder = new ViewTitleHolder (); 56 holder. TV _title = (TextView) convertView. findViewById (R. id. TV _title); 57 convertView. setTag (holder); 58} else {59 holder = (ViewTitleHolder) convertView. getTag (); 60} 61 if (position = 0) {62 holder. TV _title.setText ("user application (" + mCustomerList. size () + ")"); 63} else {64 holder. TV _title.setText ("System Application (" + mSystemList. size () + ")"); 65} 66 return convertView; 67} else {68 // display image + text entry 69 ViewHolder holder = null; 70 if (convertView = null) {71 convertView = View. inflate (getApplicationContext (), R. layout. listview_app_item, null); 72 holder = new ViewHolder (); 73 holder. iv_icon = (ImageView) convertView. findViewById (R. id. iv_icon); 74 holder. TV _name = (TextView) convertView. findViewById (R. id. TV _name); 75 holder. TV _path = (TextView) convertView. findViewById (R. id. TV _path); 76 convertView. setTag (holder); 77} else {78 holder = (ViewHolder) convertView. getTag (); 79} 80 holder. iv_icon.setBackgroundDrawable (getItem (position ). icon); 81 holder. TV _name.setText (getItem (position ). name); 82 if (getItem (position ). isSdCard) {83 holder. TV _path.setText ("SD card application"); 84} else {85 holder. TV _path.setText ("mobile app"); 86} 87 return convertView; 88} 89} 90}

 

2.Resident Floating frame usage

Listener (new OnScrollListener () {@ Overridepublic void onScrollStateChanged (AbsListView view, int scrollState) {}@ Overridepublic void onScroll (AbsListView view, int cursor, int visibleItemCount, int totalItemCount) {// call method during the rolling process // view in AbsListView is the index value of the first visible entry in the listView object // firstVisibleItem // visibleItemCount number of visible entries on the current screen // total number of entries if (mCustomerList! = Null & mSystemList! = Null) {if (firstVisibleItem> = mCustomerList. size () + 1) {// scroll to the system entry TV _des.setText ("System Application (" + mSystemList. size () + ")");} else {// scroll to the user application entry TV _des.setText ("user application (" + mCustomerList. size () + ")");}}}});

 

3. activity_app_manager.xml

<FrameLayout android:layout_width="match_parent"android:layout_height="wrap_content"><ListView android:id="@+id/lv_app_list"android:layout_width="match_parent"android:layout_height="wrap_content"></ListView><TextView android:background="#ccc"android:id="@+id/tv_des"android:textColor="#000"android:textSize="18sp"android:layout_width="match_parent"android:layout_height="wrap_content"/></FrameLayout>

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.