android登陆界面设计方案,011android初级篇之android登录界面的设计

设计目标

密码账户的输入

输入账户时,自动显示匹配账户

没有帐号,显示官网超链接

登录框的自动提示功能参考一下链接中的AutoCompleteTextView的使用

布局文件

android:orientation="vertical" android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@drawable/background_login">

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:padding="15dip"

android:layout_margin="15dip"

android:background="@drawable/background_login_div">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentTop="true"

android:layout_marginTop="5dp"

android:text="@string/login_label_username"

android:id="@+id/login_user_input"

/>

android:id="@+id/username_edit"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:hint="@string/login_username_hint"

android:layout_below="@+id/login_user_input"

android:singleLine="true"

android:inputType="text"

/>

android:id="@+id/login_passwd_input"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_below="@+id/username_edit"

android:layout_marginTop="3dp"

android:text="@string/login_label_passwd"/>

android:id="@+id/passwd_edit"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_below="@id/login_passwd_input"

android:password="true"

android:singleLine="true"

android:inputType="textPassword"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/login_button"

android:layout_below="@id/passwd_edit"

android:layout_alignRight="@id/passwd_edit"

android:text="@string/login_label_signin"

/>

android:layout_width="fill_parent"

android:layout_height="wrap_content">

android:id="@+id/infoWords"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/login_register_link"

android:layout_marginLeft="15dp"

android:textColor="#888"

android:textColorLink="#FF0066CC"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/cat"

android:layout_alignParentRight="true"

android:layout_alignParentBottom="true"

android:layout_marginRight="25dp"

android:layout_marginLeft="10dp"

android:layout_marginBottom="25dp"

android:id="@+id/logo"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/logo"

android:layout_toLeftOf="@id/logo"

android:layout_alignBottom="@id/logo"

android:layout_marginBottom="25dp"

/>

编程代码

public class LoginActivity extends Activity {

private static final String TAG = "LoginActivity" ;

Button loginButton;

EditText username_edit;

EditText passwd_edit;

TextView infoWords;

public void onCreate(Bundle savedInstanceState){

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.login);

username_edit = (EditText)findViewById(R.id.username_edit);

passwd_edit = (EditText)findViewById(R.id.passwd_edit);

infoWords = (TextView)findViewById(R.id.infoWords);

infoWords.setMovementMethod(LinkMovementMethod.getInstance());

loginButton =(Button) findViewById(R.id.login_button);

loginButton.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

String user=username_edit.getText().toString().trim();

String passwd=passwd_edit.getText().toString().trim();

if(checkAcount(user,passwd)){

setResult(RESULT_OK);

finish();

}

else {

Toast.makeText(LoginActivity.this, "用户名密码不正确,请重新输入!", Toast.LENGTH_LONG).show();

}

}

});

}

boolean checkAcount(String user,String passwd){

// TODO: 2015/11/9

Log.w(TAG,"checkAcconut "+user + passwd);

if(user == "test" && passwd == user){

return true;

}

return false;

}

}

在TextView中设置超链接

有两种方式

第一种

没有帐号,注册

android:id="@+id/infoWords"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/login_register_link"

android:layout_marginLeft="15dp"

android:textColor="#888"

android:textColorLink="#FF0066CC"/>

textView.setMovementMethod(LinkMovementMethod.getInstance());

第二种

String html = "有问题:\n";

html+="www.baidu.com";//这里即使不加协议好HTTP;也能自动被系统识别出来。

textView.setText(html);

textView.setAutoLinkMask(Linkify.ALL);

textView.setMovementMethod(LinkMovementMethod.getInstance());

参考链接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值