1 . Adding different types of entries
1 classMyadapterextendsbaseadapter{2 3 //gets the total number of entry types in the data adapter, modified into two types (plain text, picture + text)4 @Override5 Public intGetviewtypecount () {6 return Super. Getviewtypecount () +1;7 }8 9 //Specifies the entry type that the index points to, the entry Type status code designation (0 (multiplexing System), 1)Ten @Override One Public intGetitemviewtype (intposition) { A if(position = = 0 | | position = = mcustomerlist.size () +1){ - //returns 0, representing the status code of the plain text entry - return0; the}Else{ - //returns 1, representing picture + text entry status code - return1; - } + } - + //Add two description entries in the ListView A @Override at Public intGetCount () { - returnMcustomerlist.size () +msystemlist.size () +2; - } - - @Override - PublicAppInfo GetItem (intposition) { in if(position = = 0 | | position = = mcustomerlist.size () +1){ - return NULL; to}Else{ + if(Position<mcustomerlist.size () +1){ - returnMcustomerlist.get (position-1); the}Else{ * //returns the object to which the system applies the corresponding entry $ returnMsystemlist.get (Position-mcustomerlist.size ()-2);Panax Notoginseng } - } the } + A @Override the Public LongGetitemid (intposition) { + returnposition; - } $ $ @Override - PublicView GetView (intposition, View Convertview, ViewGroup parent) { - intType =Getitemviewtype (position); the - if(Type = = 0){Wuyi //Show Gray Plain text entries theViewtitleholder holder =NULL; - if(Convertview = =NULL){ WuConvertview = View.inflate (Getapplicationcontext (), R.layout.listview_app_item_title,NULL); -Holder =NewViewtitleholder (); AboutHolder.tv_title =(TextView) Convertview.findviewbyid (r.id.tv_title); $ Convertview.settag (holder); -}Else{ -Holder =(Viewtitleholder) Convertview.gettag (); - } A if(Position = = 0){ +Holder.tv_title.setText ("User Application (" +mcustomerlist.size () + ")"); the}Else{ -Holder.tv_title.setText ("System Application (" +msystemlist.size () + ")"); $ } the returnConvertview; the}Else{ the //Display picture + text entry theViewholder holder =NULL; - if(Convertview = =NULL){ inConvertview = View.inflate (Getapplicationcontext (), R.layout.listview_app_item,NULL); theHolder =NewViewholder (); theHolder.iv_icon =(ImageView) Convertview.findviewbyid (R.id.iv_icon); AboutHolder.tv_name =(TextView) Convertview.findviewbyid (r.id.tv_name); theHolder.tv_path =(TextView) Convertview.findviewbyid (R.id.tv_path); the Convertview.settag (holder); the}Else{ +Holder =(Viewholder) Convertview.gettag (); - } the holder.iv_icon.setBackgroundDrawable (GetItem (position). icon);Bayi Holder.tv_name.setText (GetItem (position). name); the if(GetItem (position). Issdcard) { theHolder.tv_path.setText ("SD card Application"); -}Else{ -Holder.tv_path.setText ("mobile app"); the } the returnConvertview; the } the } -}
2. Permanent suspension box use
Lv_app_list.setonscrolllistener (New Onscrolllistener () {@Overridepublic void onscrollstatechanged (Abslistview view, int scrollstate) {} @Overridepublic void Onscroll (abslistview view, int firstvisibleitem,int visibleitemcount, int Totalitemcount) {///Scroll procedure called method//abslistview in view is the ListView object//firstvisibleitem the first visible entry index value// VisibleItemCount the number of visible entries for the current screen//total number of entries if (Mcustomerlist!=null && msystemlist!=null) {if (firstvisibleitem> =mcustomerlist.size () +1) {//Scroll to System entry Tv_des.settext ("System Application (" +msystemlist.size () + ")");} else{//Scroll to User app entry Tv_des.settext ("User app (" +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>
Android Mobile defender 10--App Manager