Android-listview last line Add control

Source: Internet
Author: User

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

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.