Android Landing Interface Design (Layoutinflater)

Source: Internet
Author: User

The Main.xml code is as follows:

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "android:orientation=" vertical "android:layout_width=" fill_parent "android:layout_height=" Fill_parent " ><button    android:id= "@+id/btn"    android:layout_height= "wrap_content"    android:layout_width= " Wrap_content "    android:text=" User login "/>    </LinearLayout>

The Login.xml code is as follows:

<?xml version= "1.0" encoding= "Utf-8"? ><tablelayout xmlns:android= "http://schemas.android.com/apk/res/   Android "android:id=" @+id/mylayout "android:layout_width=" fill_parent "android:layout_height=" Fill_parent "> <TableRow> <textview android:text= "user name:" android:layout_marginleft= "20dip" a       Ndroid:textsize= "8px" android:layout_height= "wrap_content" android:layout_width= "Wrap_content"/>   <edittext android:width= "60pt" android:layout_width= "wrap_content"/> </TableRow>           <tablerow > <textview android:text= "Password:" android:layout_marginleft= "20dip"       Android:textsize= "8px" android:layout_height= "wrap_content" android:layout_width= "Wrap_content"/> <edittext android:password= "true" android:width= "60pt" android:layout_width= "Wrap_ Content "/> </tablerow></tablelayouT> 

. Java code is as follows:

Package Org.lxh.demo;import Android.app.activity;import Android.app.alertdialog;import android.app.Dialog;import Android.content.dialoginterface;import Android.os.bundle;import Android.view.layoutinflater;import Android.view.view;import Android.view.view.onclicklistener;import Android.widget.adapterview;import Android.widget.adapterview.onitemclicklistener;import Android.widget.adapterview.onitemselectedlistener;import Android.widget.button;import Android.widget.spinner;import Android.widget.textview;public class Hello extends Activity {private Button btn = null, @Overridepublic void OnCreate (Bundle savedinstancestate) {super.oncreate ( Savedinstancestate); Life cycle Method Super.setcontentview (R.layout.main); Set the layout manager to use THIS.BTN = (Button) Super.findviewbyid (R.ID.BTN); This.btn.setOnClickListener (New Onclicklistenerimpl ( ));} Private class Onclicklistenerimpl implements Onclicklistener {public void OnClick (View v) {Layoutinflater factory = Layout Inflater.from (Hello.this); View MyView = factory.inFlate (R.layout.login, null);D ialog Dialog = new Alertdialog.builder (hello.this). Settitle ("User Login"). Setview (MyView). Setpositivebutton ("Login", new Dialoginterface.onclicklistener () {public void OnClick (Dialoginterface arg0,int arg1) {}}) . Setnegativebutton ("Cancel", new Dialoginterface.onclicklistener () {public void OnClick (Dialoginterface arg0,int arg1) {}} ). Create ();d ialog.show ();}}}
Run as follows:

Download Source: http://download.csdn.net/detail/yayun0516/8378881

Android Landing Interface Design (Layoutinflater)

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.