Android_ String Conversions

Source: Internet
Author: User

This is very simple, just an input box, a button, a textview used to display the converted string, the button has an event, the use of visual interface to add, after all, it is very convenient!

Layout file Code:

1 <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"2 Xmlns:tools= "Http://schemas.android.com/tools"3 Android:id= "@+id/linearlayout2"4 Android:layout_width= "Match_parent"5 Android:layout_height= "Match_parent"6 android:orientation= "vertical"7 Android:paddingbottom= "@dimen/activity_vertical_margin"8 Android:paddingleft= "@dimen/activity_horizontal_margin"9 Android:paddingright= "@dimen/activity_horizontal_margin"Ten Android:paddingtop= "@dimen/activity_vertical_margin" One Tools:context=". Mainactivity " > A  -     <LinearLayout -         Android:layout_width= "Match_parent" the Android:layout_height= "Wrap_content" > -  -         <TextView -             Android:layout_width= "Wrap_content" + Android:layout_height= "Wrap_content" - Android:text= "lowercase string:" /> +  A         <EditText at             Android:id= "@+id/etl" - Android:layout_width= "Wrap_content" - Android:layout_height= "Wrap_content" - Android:layout_weight= "1" - Android:ems= "Ten" > -  in             <Requestfocus/> -         </EditText> to  +     </LinearLayout> -  the     <Button *         Android:id= "@+id/bnt1" $ Android:layout_width= "Match_parent"Panax Notoginseng Android:layout_height= "Wrap_content" - Android:onclick= "Btnconvert_click" the Android:text= "Convert" /> +  A     <TextView the         Android:id= "@+id/tvresult" + Android:layout_width= "Wrap_content" - Android:layout_height= "Wrap_content" $ Android:text= "Uppercase string:" /> $  - </LinearLayout>

Java files:

1  Packagecom.dc365.t1;2 3 ImportAndroid.os.Bundle;4 Importandroid.app.Activity;5 ImportAndroid.view.Menu;6 ImportAndroid.view.View;7 ImportAndroid.widget.EditText;8 ImportAndroid.widget.TextView;9 Ten  Public classMainactivityextendsActivity { One   A     //variable *********************************************************************** -     PrivateEditText ETL =NULL; -     PrivateTextView result =NULL; the      -     //function *********************************************************************** - @Override -     protected voidonCreate (Bundle savedinstancestate) { +         Super. OnCreate (savedinstancestate); - Setcontentview (r.layout.activity_main); +Etl=(EditText) Findviewbyid (r.id.etl); Aresult=(TextView) Findviewbyid (r.id.tvresult); at     } -  - @Override -      Public BooleanOncreateoptionsmenu (Menu menu) { -         //inflate the menu; This adds items to the action bar if it is present. -         //getmenuinflater (). Inflate (R.menu.main, menu); in         return true; -     } to      +      -      Public voidBtnconvert_click (View v) the     { *String s= ""; $s=Etl.gettext (). toString ();Panax Notoginsengs=s.touppercase (); -Result.settext ("Uppercase string:" +s); the     } +}

Operating effect:

Android_ String Conversions

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.