一个简单的Android程序的登录界面

最近在学习Android所以学了这个简单的Android登录程序,用来激励自己认真学下去。

1.activity_main.xml里面的代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    android:orientation="vertical" >


    <TextView
        android:id="@+id/html"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20sp" />
    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/name"/>
    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/psd"
        />
    <Button 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/login"/>
    <Button 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/register"/>
     <TextView


        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="18sp" 
        android:textColor="#0000ff"
        android:autoLink="all"
        android:text="@string/test"/>

</LinearLayout>

2.String.xml中的代码:

<?xml version="1.0" encoding="utf-8"?>
<resources>


    <string name="app_name">TextView</string>
    <string name="hello_world">Hello world!</string>
    <string name="action_settings">Settings</string>
    <string name="title_activity_main">竞争登录</string>
    <string name="test">你的才华如滔滔江水连绵不绝!</string>
    <string name="name">请输入你的姓名</string>
    <string name="psd">请输入你的密码</string>
    <string name="login">登录</string>
   <string name="register">注册</string>
</resources>

3.MainActivity 中的代码:

package com.jxufe.helloworld;


import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.text.Html;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.os.Build;


public class MainActivity extends ActionBarActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView html = (TextView) findViewById(R.id.html);
        
        html.setText(Html.fromHtml(" Welcome to China."));
    }




}





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值