Today in doing a function, the requirement must be under a ListView, there is a hint of the line of text, their own ListView adapter with CursorAdapter, so that the flexibility to deal with the layout is greatly compromised. The first idea is to change the layout of the item and then handle it in adapter, ensuring that the TextView display added in the item is controlled when the ListView is loaded into the last row. However, there are a lot of problems to be faced at this time. For example, the last line hits the event, the last line underlines, and so on.
Later, think of another way, is no longer adapter added, but directly in the ListView Add, this is a good solution to the problem. The code is as follows
/*Vanzo:zhangshuli On:sat, 16:21:40 +0000*/ PrivateView Maddslideitem; PrivateTextView Msearchresult;//End of Vanzo:zhangshuli Public voidonCreate1 (Bundle icicle) {mmslog.d (TAG,"OnCreate");
Initplugin ( This, Getintent ());
Sneedrequery =true;
FinalUri U =getintent (). GetData (); if(U! =NULL&& u.getqueryparameter ("source_id")! =NULL) {
gotocomposemessageactivity (U)
; return; } contentresolver CR=getcontentresolver ();
Mlayoutsearch=(relativelayout) Findviewbyid (R.id.conv_second); Mlayoutsearch.setvisibility (View.gone);
Get the control you want to add
Maddslideitem=( (Layoutinflater) Getsystemservice (Context.layout_inflater_service)). Inflate (R.layout.search_mms_ result,NULL);
Msearchresult=(TextView) Maddslideitem.findviewbyid (r.id.search_result);
Msearchlistview =(ListView) Findviewbyid (R.ID.LIST2); Msearchlistview.setitemscanfocus (true); Msearchlistview.setfocusable (true); Msearchlistview.setclickable (true);//Add controls at the end
Msearchlistview. Addfooterview(maddslideitem);
Mtvempty=(TextView) Findviewbyid (Android. R.id.empty);
Settitle (""); Contact.addlistener (Mcontactlistener);
MQueryHandler2 =NewAsyncqueryhandler (CR) {protected voidOnquerycomplete (inttoken, Object cookie, Cursor c) {
Try { if(Searchprogressdialog! =NULL&&searchprogressdialog.isshowing ()) {Searchprogressdialog.setdismiss (true); Searchprogressdialog.dismiss (); } } Catch(IllegalArgumentException ex) {MMSLOG.D (TAG,"Dialog.dismiss () illegalargumentexception"); } if(miscontentchanged) {Swaitsavedraft=false; Miscontentchanged=false; } misquerycomplete=true; /// @} if(c = =NULL) { ///M:add for OP09: @{
Msearchlistview.setfocusable (true); Msearchlistview.setfocusableintouchmode (true); Msearchlistview.requestfocus (); //Remember The query if there is actual results if(Cursorcount > 0) {searchrecentsuggestions recent=( (Mmsapp) getapplication ()). Getrecentsuggestions (); if(Recent! =NULL) {recent.saverecentquery (SearchString, getString (r.string.search_history, Cursorcount, search String)); } }
Although you have added your own controls here, if you want to refresh the state of this control, you need to be similar to the ListView refresh, that is, each time you want to
Android-listview last line Add control