Android--autocompletetextview, spinner, and message tips

Source: Internet
Author: User

Layout file:

1 <?XML version= "1.0" encoding= "Utf-8"?>2 <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"3 Xmlns:tools= "Http://schemas.android.com/tools"4 Android:layout_width= "Match_parent"5 Android:layout_height= "Match_parent"6 Android:paddingbottom= "@dimen/activity_vertical_margin"7 Android:paddingleft= "@dimen/activity_horizontal_margin"8 Android:paddingright= "@dimen/activity_horizontal_margin"9 Android:paddingtop= "@dimen/activity_vertical_margin"Ten Tools:context= "Com.hanqi.testapp2.TestActivity10" One android:orientation= "vertical"> A  -     <Autocompletetextview -         Android:layout_width= "Match_parent" the Android:layout_height= "Wrap_content" - Android:hint= "Please enter" - Android:id= "@+id/at_1" - Android:completionthreshold= "1"/> +     <LinearLayout -         Android:layout_width= "Match_parent" + Android:layout_height= "Wrap_content"> A         <TextView at             Android:layout_width= "Wrap_content" - Android:layout_height= "Wrap_content" - Android:text= "Education:"/> -         <Spinner -             Android:layout_width= "0DP" - Android:layout_weight= "1" in Android:layout_height= "Wrap_content" - Android:id= "@+id/sp_1"></Spinner> to     </LinearLayout> + <Button -     Android:layout_width= "Match_parent" the Android:layout_height= "Wrap_content" * Android:text= "Send status bar message" $ Android:onclick= "Bt_onclick"/>Panax Notoginseng </LinearLayout>

Java class:

1  Packagecom.hanqi.testapp2;2 3 Importandroid.app.Notification;4 ImportAndroid.app.NotificationManager;5 Importandroid.app.PendingIntent;6 Importandroid.content.Intent;7 Importandroid.support.v7.app.AppCompatActivity;8 ImportAndroid.os.Bundle;9 ImportAndroid.view.View;Ten ImportAndroid.widget.AdapterView; One ImportAndroid.widget.ArrayAdapter; A ImportAndroid.widget.AutoCompleteTextView; - ImportAndroid.widget.Spinner; - ImportAndroid.widget.Toast; the  -  Public classTestActivity10extendsappcompatactivity { -  - Autocompletetextview at_1; + Spinner sp_1; - @Override +     protected voidonCreate (Bundle savedinstancestate) { A         Super. OnCreate (savedinstancestate); at Setcontentview (r.layout.activity_test10); -At_1 =(Autocompletetextview) Findviewbyid (r.id.at_1); -Sp_1 =(Spinner) Findviewbyid (r.id.sp_1); -         //preparing the data source -String[] strings = {"abc", "and", "Bea", "Car", "afcgy", "Ctret", "Auyn"}; -         //preparing the adapter inArrayadapter<string> arrayadapter=NewArrayadapter<string> ( This, r.layout.arry_adapter,strings); -         //to set an adapter for a component to At_1.setadapter (arrayadapter); +  -         //Drop- down list the         FinalString[] xl = {"High school", "specialty", "undergraduate", "Master", "PhD"}; *Arrayadapter<string> SP =NewArrayadapter<string> ( This, R.LAYOUT.ARRY_ADAPTER,XL); $ Sp_1.setadapter (SP);Panax Notoginseng         //Monitor -Sp_1.setonitemselectedlistener (NewAdapterview.onitemselectedlistener () { the @Override +              Public voidOnitemselected (adapterview<?> Parent, view view,intPositionLongID) { AToast.maketext (TestActivity10. This, "Selected item is" +Xl[position], toast.length_short). Show (); the             } +  - @Override $              Public voidOnnothingselected (adapterview<?>parent) { $Toast.maketext (TestActivity10. This, "No choice", Toast.length_short). Show (); -             } -         }); the     } -     //Send MessageWuyi      Public voidBt_onclick (View v) the     { -         //1. Get status Bar message manager WuNotificationmanager nm =(Notificationmanager) Getsystemservice (notification_service); -  About         //Prepare Pendingintent $         //1) Create intent -Intent Intent =NewIntent ( This, TestActivity1.class); -         //2) Generate -pendingintent pi = pendingintent.getactivity ( This, 0, intent, 0); A         //2. Build status bar Messages +Notification NT =NewNotification.builder ( This) the. Setcontenttitle ("Weather Forecast") -. Setcontenttext ("Tomorrow is fine, the temperature is 30°") $ . Setsmallicon (R.drawable.gmail) the. Setticker ("New Weather Forecast") the . SetDefaults (Notification.default_sound) the. Setautocancel (false) the . Setcontentintent (PI) - . Build (); in         //3. Sending messages by manager theNm.notify (0, NT); the     } About}

For:

Clicking on the status notification bar jumps to another activity interface

Related Mind Mapping:

Android--autocompletetextview, spinner, and message tips

Related Article

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.