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
= (TextView)
ConvertView. findViewById (R. id.Info);
// Wonderful use of setTag
ConvertView. setTag (holder );
}Else{
Holder = (ViewHolder) convertView. getTag ();
}
...... Omitted
}Example 3 In The onClick event, use the tag
SetTag ()/getTag ()
The setTag (Onbect) in the View indicates that an extra data is added to the View. In the future, you can use getTag
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
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
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. O
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
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
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
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
Demand-driven technology, with new requirements, new technologies emerge when old technologies cannot be implemented.General app jump requirements are as follows:1. Jump from your app to someone else's app.2. Jump the system app from your app.3. Let someone else's
Boss temporarily let me do a demo, to implement an app to open another app
Requirements: Click on the Open button, have installed the words opened, no installation display installation
Sub-program can no longer display icon on mobile phone page
Parent Program Core Code
public void OnClick (View arg0) {
//TODO auto-generated method stub
Intent Intent = new Intent ();
COM.E
I had an egg today. Clear the right-click menu, and then, at some point, use everything's "double-click Path column to open Directory" feature when you find an exception:[Window Title] Everything.exe[content] The file does not have an app associated with it to perform the operation. Please install the app and, if the app is already installed, create an associatio
First, what is the native App?The Native app is the native app, which we generally call the client, is a standalone application developed for different mobile systems, and the most common way to download the Native app is to access the App store, such as the Apple
Editor's note: Do you know all these 3 mainstream applications? Designers in addition to have visual Kung Fu, to different forms of the app should also be clear on the chest, today Baidu classmate wrote a very comprehensive summary, to help you quickly fix 3 kinds of mainstream app design method, with a large wave of lightning rod, with you cleverly skip the app
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.