Zookeeper
The Spinner function can pop up a dialog box list, as shown in most forms:
This form is not beautiful enough for the project, so many people re-simulate it. Using listview and popwindow, in fact, the Spinner can also be in the following state.
The reason is that you have changed his topic. Many times we have removed the title from development, and most developers will use it in AndroidM
Drag the icon on the panel to the interface, and add the following code in res/strings. xml:
First, add the description text of the List header;
The second item is the content of each item in the list;
Finally, modify related items in Properties, such:
The activity_main.xml list is as follows:
Android: id = "@ + id/spin01"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_alignRight = "@ + id/btnOk"
Android: layout_below = "@ + id/radioG
This blog post describes how to use the basic spinnerFirst write the Code section in XMLWrite the file section in Strings.xml again.Finally, let's show you the Code section of the activity.publicclassmainactivityextendsactivity{privatespinnerspin; @Override protectedvoidoncreate (bundle savedinstancestate) {super.oncreate (savedInstanceState); setcontentview (R.layout.activity_main); spin= (Spinner) Findviewbyid (R.id.myspinner); arrayadapterThis art
Hello everyone! Today, I want to explain how to use baseadapter (Basic adapter). The adapter is mainly used to fill data for (such as spinner, listview, and gridview. While (spinner, listview, and gridview) all have their own adapters (difficult to remember ). However, baseadapter is common to them. Why? First, let's take a look at the API documentation:
We can see that baseadapter has implemented the list
In android, you can change the color of the spinner and AutoCompleteTextView splitters. In android, The splitters
The method for removing the split line was not found for a long time. Finally, the method for changing the split line was found.
The spinner and AutoCompleteTextView prompts that there is a black split line in the list. To change its color value, rewrite the style.
1. Write a style in themes
Checkbox:
Declaration in XML
Define in activity:
Mycheckbox = (checkbox) findviewbyid (R. Id. mycheckbox );
Add a listener event:
Mycheckbox. setonclicklistener (New checkbox. onclicklistener ()
Multiple checkboxes can be used to construct multiple checkboxes.
Radiogroup and radiobutton:
XML declaration, radiogroup puts the radiobutton package in it:
Definition in activity:
Mradiogroup1 = (radiogroup) findviewbyid (R. id. myradiogroup);
Listener function:
Private radiogroup. oncheckedchange
The effect is as follows:
C # implementation Code
Using Android.app;
Using Android.os;
Using Android.widget; namespace Spinnerdemo {[Activity (Label = "@string/applicationname", Mainlauncher = true, Icon = "@drawable/icon")] Pu
Blic class Mainactivity:activity {private Spinner _cityspinner;
Private TextView _citynameview;
Private arrayadapter
Java Implementation Code
Package Com.example.halower.spinnerdemo;
Impor
Example 1Directly designated Android:entries, it is relatively simple, but the general selection box is enoughItems.xmlXML version= "1.0" encoding= "Utf-8"?>Resources> String-arrayname= "Ys"> Item>RedItem> Item>GreenItem> Item>YellowItem> String-array>Resources>View CodeActivity_main.xmlRelativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match
The scenario exception information is as follows:android.view.windowmanager$badtokenexception:unable to add window-token [email protected] was not valid; Is your activity running?At Android.view.ViewRootImpl.setView (viewrootimpl.java:646)At Android.view.WindowManagerGlobal.addView (windowmanagerglobal.java:248)At Android.view.WindowManagerImpl.addView (windowmanagerimpl.java:69)At Android.widget.PopupWindow.invokePopup (popupwindow.java:993)At Android.widget.PopupWindow.showAsDropDown (popupwin
In the development of Android, often need to add address, here is a simple according to the XML file to parse to obtain the linkage of the provincial and municipal addressFirst in the Res directory to create a new folder XML, put the XML file in this folder, the format of XML, the detailed file in the download demoWrite a method to get the address in the XML filepublic void Getxmldata () {//Gets the resource in the XML file Xmlresourceparser parser = Getresources (). GETXML (r.xml.citys_weather)
Most of the time, we bind a value to the drop-down menu, but the spinner does not provide such a service.
So I searched for a long time on the Internet and finally found a simple and easy-to-use solution.
First, define an item class. Note the following:
The. tostring () function to override itBecause when the adapter displays data, if the object passed into the adapter is not a string, the object. tostring () is directly used ()
Public class citem
1. store data in array. xml
The content of array. XML is as follows:
2. InProgramTo call the spzone is my spinner control, and the layout of the drop-down list is the default layout of a drop-down list of Android. I set the string zone to null when "NONE" is displayed.
Spzone. setadapter (arrayadapter. createfromresource (this, R. array. newhouse_check_zone, android. r. layout. simple_spinner_dropdown_item); spzone. setonitemselectedlistener (N
: startactivity (); startactivityforresult ();//note Use scene, view Demo2 (iv) Exchange of data between activity:The first way:A page uses the Putextra () method of the intent object to pass the value, b page uses Getstringextra (), Getintextra () and other series method to receive the value one by one;The second way: "Common"A page uses the bundle object to save all the values that need to be passed through the intent Putextras () method, and the B page returns the bundle object using the Ge
Introduced
Distinctive Windows Phone 7.5 (SDK 7.1) Selector
Addresschoosertask-Select the address of the contact person
Emailaddresschoosertask-Select the email of the contact person
Phonenumberchoosertask-Select a contact person's phone
The file selector in Windows 8 is quite different from the previous versions of Windows, and this article will explain how to use the Windows file selector for single and multiple files, and also to look at the file and folder selectors.
Before
First of all, this bug appears in your implements this listener, if it is an anonymous internal class implementation of the words can beSee the reason why the listener is invalid on the internet implementsAs if the thread, when listening, the thread
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.