In this project, the problems encountered when using Spiner in tabhost are summarized.
What needs to be changed during oncreate on the page is:
View contentview = layoutinflater. From (getparent (). getparent (). Inflate (R. layout. personal_information, null );Setcontentview (contentview );
In this way, you can set the view displayed on the page.
Personalprovincespinner = (spinner) contentview. findviewbyid (R. Id. personalprovincespinner); in
Spinner:is a control similar to a drop-down list from which the user chooses the appropriate option!The data in the spinner needs to be populated with a adapter (adapter).Use:layout file Activity_main.xml: class file Mainactivity.java: Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. Android Self-study note the Spinner drop-down box features, use
MainActivity is as follows:
Package cc. test; import android. app. activity; import android. OS. bundle; import android. view. view; import android. widget. adapterView; import android. widget. arrayAdapter; import android. widget. spinner; import android. widget. adapterView. onItemSelectedListener;/*** Demo Description: * Complete example of modifying the font size and color of the built-in Spinner in the
This tutorial is simple and practical, people like the words can pay attention to me, thank you!A drop-down list box is a common graphical component that can effectively save screen space compared to other selection components and can be implemented using the Android.widget.Spinner class in Android.The list items in the drop-down list box are configured in the following two ways.Method one, through the resource file configuration, such as the definition of a values\city_data.xml file, when defin
The list items for the Spinner drop-down list box are configured in two ways:1. Through the resource file configuration, the list item content is added by using the 2. Read the resource file through the Android.widget.ArrayAdapter class or specify the specific settings data.One: How the resource files are configured.XML version= "1.0" encoding= "Utf-8"?>Resources> stringname= "App_name">ADTeststring> stringname= "Hello_world">Hello world!string>
This article was written based on your understanding after reading the instructor's teaching video. Therefore, some of the content is referenced in the video.
PS: we strongly recommend that you read a video from a friend who is new to Android.
Body:
The spinner control is like the drop-down menu of our computer. However, because the display range of the mobile phone screen is limited, a menu similar to the dialog box is displayed. For example:
------
This example describes the use of the Android spinner menu. Share to everyone for your reference, specific as follows:
One, using arrays as data sources
1. In the layout layout file: Declare a TextView control and a spinner control with the following code
2. Add the following code to the activity file
Import android.app.Activity;
Import Android.os.Bundle;
Import Android.view.View;
Impor
Today, I learned the use of spinner components, a very useful component, the equivalent from the Drop-down list to select items, today a lot of harvest, the following to show you the use of spinner (respectively using Arrayadapter and custom adapter implementation), the specific contents are as follows.
(i): Use of Arrayadapter for data adaptation:
①: First define a layout file:
"Note:" The
First look at the effect, I feel better than spinner effect, record the implementation process.
Final string[] Levelarray = Getresources (). Getstringarray (R.array.contact_level); Re_layout_spinner.setonclicklistener (New Onclicklistener () {@Override public void OnClick (View v) {//TODO Au
to-generated method Stub if (!isexpand) {Dialog = New dialog (mself);
Dialog.requestwindowfeature (Window.feature_no_title);
ListView Mlistview =
In the development we often encounter similar spinner cascading menu effect, the following is the implementation of spinner cascading menu effectActivity_main.xml123Android:layout_width= "Fill_parent"4android:layout_height= "Fill_parent"5android:orientation= "Vertical" >6 7LinearLayout8Android:layout_width= "Fill_parent"9android:layout_height= "Wrap_content"Tenandroid:orientation= "Horizontal" > One A - -
Android gives us a spinner control, which is basically a list, so let's say this control, this control has been seen in the past, but this is still a new introduction again. Spinner is located under the Android.widget package, displaying only the user-selected element at a time, and when the user taps again, a selection list pops up for the user to select, and the elements from the selection list are also f
Tonight I saw the next spinner. The use of the control, combined with the blog of the Great God Tutorial, a small demoOne, spinneractivity PrivateSpinner Spinner; PrivateArrayadapteradapter; PrivateListlist; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_spinner); List=NewArraylist();
Here's how to set up a data source for a spinner control in a program by using a collection, in the following steps:1. In the Android Studio interface, select Project, and then expand "Application", "res", "Layout", open Activity_main.xml, add a spinner control, the code is as follows:2, find the "app", "Java" under the Mainactivity.java file, define a few variables, the code is as follows:Private list3. Af
Figure:Introduce several methods:1.setAdapter ()Use the Spinner drop-down list to set the adapter. such as: Arrayadapter and so on.2.setPrompt ()Used to set the caption for the spinner drop-down list, with the argument string. (displayed only in the dialog style, as shown on the left, no longer in the drop-down style, as on the right)3. Setpromptid ()Use the Spinner
Implementation of effects (source code implementation) of custom Spinner styles in Android Development
The built-in Spinner style of the android system is far from satisfying the requirements of the Spinner UI style in our actual development process. Therefore, we must modify our Spinner style to suit the style of the
Spinner (List Options box) Autocompletetextview (auto-complete text box)I. List option box Core propertiesAndroid:dropdownhorizontaloffset set the horizontal offset distance of the list boxAndroid:dropdownverticaloffset to set the horizontal vertical distance of a list boxAndroid:dropdownselector setting list is selected when backgroundAndroid:dropdownwidth Setting the width of a drop-down list boxAndroid:gravity sets the way in which components are
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.