Purely entertainment, to get started Android has certain help

Source: Internet
Author: User

Package android.m9; Import Android.app.activity;import android.os.bundle;import Android.view.menu;import Android.view.MenuItem;import Android.view.view;import Android.view.view.onclicklistener;import Android.widget.button;import Android.widget.edittext;import Android.widget.TextView; public class HelloWorld extends Activity {private TextView logo;private EditText et;private Button Reset, submit;private EditText result;private String name;private String LastName = "";private int rp;/** Called when the activity is first created. * /@OverridePublic void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);Setcontentview (r.layout.main); // ///////////////////////////////////////////////Logo setlogo = (TextView) Findviewbyid (r.id.textview_1);Logo.settext (R.string.logo); // //////////////////////////////////////////////EditText setet = (EditText) Findviewbyid (r.id.edittext_1);Et.settext (r.string.inputtip); // //////////////////////////////////////////////Button Set:resetreset = (Button) Findviewbyid (r.id.button_1);Reset.settext (r.string.reset);Reset.setonclicklistener (New Onclicklistener () {Public void OnClick (View v) {Et.settext (r.string.inputtip);Result.settext (""); } });//button Set:resetsubmit = (Button) Findviewbyid (r.id.burron_2);Submit.settext (r.string.submit);Submit.setonclicklistener (New Onclicklistener () {Public void OnClick (View v) {name = Et.gettext (). toString ();if (!lastname.equals (name)) {RP = (int) (Math.random () *);Result.settext ("Tester name:" + name + "\ n" + "character score:" + RP);lastName = name;http://www.huiyi8.com/webyuanma/} else {Website source code Downloadresult.settext ("Please replace the tester!\n\n the name of the tester:" + name + "\ n" )+ "character score:" + RP); } } }); // //////////////////////////////////////////////TextView setresult = (EditText) Findviewbyid (r.id.edittext_2);result.setenabled (false);Result.settextcolor (Android.graphics.Color.BLUE); }@OverridePublic Boolean Oncreateoptionsmenu (Menu menu) {menu.add (0, 1, 1, r.string.exit);return Super.oncreateoptionsmenu (menu); }@OverridePublic Boolean onoptionsitemselected (MenuItem item) {if (item.getitemid () = = 1) {finish (); }return super.onoptionsitemselected (item); }}

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.