Android: Use the setTag () and getTag () Methods of View
We usually use the findViewById () method to obtain the View control we want to use. However, in addition to this method, we can also use the setTag (Onbect) in the View) add an extra data to the View and use getTag () to obtain the corresponding View. The setTag () and getTag () methods are often used to p
Write a custom adapter to bind the listview. When rewriting getview, I found that the online reference code used the settag () and gettag () functions. Baidu could not find the answer, google will find it: P
The settag (onbect) in the view indicates that an extra data is added to the view. In the future, you can use gettag () to retrieve this data.
You can use multiple buttons to add a listener. Each butto
This is useful when you need to use the adapter custom control display mode.The adapter has a getview method. You can use settag to cache the view to facilitate multiple reuse.
Public View getview (INT position, view convertview, viewgroup parent ){Viewholder VL;
If (convertview = NULL ){Layoutinflater Inflater = (layoutinflater) mwidgetsswitchapp. Getsystemservice (context. layout_inflater_service );Convertview = Inflater. Inflate (R. layout. app_gallery_item, null );Vl = new viewholder ();Vl.
Title: Method Settag (), Gettag () play a role in viewWhy I find such a problem, the main reason is that I encountered when learning Viewholder, then only know how to use. At Google, I found a good explanation on StackOverflow. Hence the translation of one or two.Source Address: Http://stackoverflow.com/questions/5291726/what-is-the-main-purpose-of-settag-gettag-methods-of-viewExplanation:For example, you c
Settag ()/gettag ()
Settag (Onbect) In view adds an extra set of data to the view, which can be taken out later with Gettag ().
You can use multiple button to add a listener, each button setting a different Settag. The listener is gettag to tell which button is being pressed.
Import android.app.Activity;
Import Android.os.Bundle;
Import Android.view.View;
Import
first we need to know what the Settag method is, he is a label to the View object, the tag can be anything, we set him up as an object here, Because we abstract the elements of Vlist2.xml into a class Viewholder, using the Settag, this tag isViewholder a property of an object after it is instantiated.we then forViewholderinstantiated ObjectsHolderthe operation, all becauseJavareference mechanism that has survived and changedConvertviewthe content, and not every time is going toNewone. We're just
Android setTag () and getTag (), and set multiple setTag ()
First, we need to know what the setTag method is.
Tags
Unlike IDs, tags are not used to identify views. tags are essentially an extra piece of information that can be associated with a view. they are most often used as a convenience to store data related to views in the views themselves rather than by putting them in a separate structure.
Unlike the ID, a Tag indicates a view. In essence,
Android: Use setTag and getTag of View
1. Used to differentiate many similar views
For example:
button1.setOnClickListener(new OnClickListener ... );button2.setOnClickListener(new OnClickListener ... );
They may execute similar logic, but you must set two independent OnClick events for the two buttons respectively,
public void onClick(View v) { doAction(1); // 1 for button1, 2 for button2, etc.}
This is because onClick has only one View paramete
Reprinted: http://www.apkbus.com/android-13264-1-1.html
Write a custom adapter to bind the listview. When rewriting getview, you will find that the online reference code is useful to the settag () and gettag () functions.
The settag (onbect) in the view indicates that an extra data is added to the view. In the future, you can use gettag () to retrieve this data.
You can use multiple buttons to add a listen
What is the main purpose of setTag () getTag () methods of View ?, SettaggettagExample: Method setTag () and getTag () play a role in View
The main reason why I found such a problem is that I only knew how to use it when I learned ViewHolder. At google, I found stackoverflow had a good explanation. Translation 2.
Source Address: http://stackoverflow.com/questions/5291726/what-is-the-main-purpose-of-settag-
); returnConvertview; }}The acquisition of Convertview involves the recycle problem of the ListView, not the focus of this article. Here is the main view of the implementation of Viewholder. The implementation of Viewholder relies on the view provided by the Settag and Gettag two methods, in order to facilitate understanding of the two methods and the behavior of the objects maintained, here is an example:Xml:Relativelayoutxmlns:android= "Http://schem
In Android, Settag (Object) is able to add a special tag to a view and then use Gettag () to get the tag.用处1:多个button设置不同tag,通过tag区分new OnClickListener() { publicvoidonClick(View v) {//获取当前view对应的数字 int cellId = (Integer) v.getTag(); cellClicked(cellId, v); } } View v; for (int020; i++) { v = findViewById(cellIDs[i]); v.setOnClickListener(listener); v.setTag(i); }用法2:在adapter中的getview实现回收的convertView的复用(这代码高亮搞不好,总是出问题)@Override public View
The settag (onbect) in the view indicates that an extra data is added to the view. In the future, you can use gettag () to retrieve this data.
You can use multiple buttons to add a listener. Each button has a different settag. The listener uses gettag to identify which button is pressed.
Import Android. App. activity; Import Android. OS. Bundle; Import Android. View. vie
This is useful when you need to use the adapter custom control display mode.The adapter has a getview method. You can use settag to cache the view to facilitate multiple reuse.
Public View getview (INT position, view convertview, viewgroup parent ){Viewholder VL;
If (convertview = NULL ){Layoutinflater Inflater = (layoutinflater) mwidgetsswitchapp. Getsystemservice (context. layout_inflater_service );Convertview = Inflater. Inflate (R. layout. app_gallery_item, null );Vl = new viewholder ();Vl.
Settag is a Android of the View a useful method in a class,In the same class, it is convenient to access data without building a database,It also saves memory more than sharepreference.Settag ( Object tag) method is relatively simpleLike whatTextView tvexecutor = (TextView) Findviewbyid (R.ID.T);Tvexecutor.settag(selectedusermap);This SelectedusermapCan make mapIt can also be the object of LinkedlistYou can store a variety of temporary data, but you can't call it a storage method.In the same cla
, delivery agent on a single truck, on a single delivery. The receiving clerk uses the PDA to scan the acceptance of the supplier order receipt. Every commodity from the supplier delivery, to the warehouse distribution, and then to the store receipts are traceable. Each car sent the line, the number of loading, distribution store customers are clearly clear.Euro-Hong YuanBlog: http://www.cnblogs.com/pdasoftqq:449188437Tel: 13530893964Date: September 4, 2014PDA
The phenomenon is as follows, iOS app embedded H5 page, originally set the white number, after two or three seconds will automatically turn black, and then click on the time will pop up whether the dialing prompt;Workaround, add the following meta tag to resolve:name= "format-detection" content= "Telephone=no"> iOS app embedded h5 page data automatic color change identification for mobile phone number resolution-
"Example 7-3 text edit box to make a simple questionnaire"Geneva Ten The Run result 7-4 as shown.When you enter content in the edit box, the page changes, such as the text in the two edit boxes of the name and phone above the page disappears automatically, a "delete" icon appears on the right side of the edit box to fill in the phone information, and the contents of the edit box are automatically deleted. In addition, the contents of the two edit boxes below the page automatically increase the h
Note: 1. Please open the WLAN hotspot first.2. If you re-enable a mobile hotspot, the traffic usage resets to zero.1. In standard mode, click "Settings".2. Click "More connection Settings".3. Click on "WLAN Hotspot and network share".4. Click "Move Hotspot".5. Click "Set mobile Data Limit".6. Read the "Set mobile data Limit" prompt, and then enter the limit value
Directly in the QQ will not show, but we can display in the QQ space, of course, mobile phone login and then online display will also show your phone model.
1. We open QQ space, and then click on "My Room"
2. We then find "personalized" entry, and then we click Open to enter
3. Select the "My Phone id" button as shown in the following image
4. Here we choose to display the mobile
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.