展会信息港展会大全

AlertDialog Builder自定义样式
来源:互联网   发布日期:2015-10-03 11:30:45   浏览:2528次  

导读:AlertDialog Builder自定义样式public void LoginDialog(final Context context){ AlertDialog.Builder builder = new AlertDialog.Builder(context); LayoutInflater inflaterDl = LayoutInf......

AlertDialog Builder自定义样式

public void LoginDialog(final Context context){

AlertDialog.Builder builder = new AlertDialog.Builder(context);

LayoutInflater inflaterDl = LayoutInflater.from(this);

LinearLayout layout = (LinearLayout)inflaterDl.inflate(R.layout.logindialog, null );

final EditText userNameET = (EditText)layout.findViewById(R.id.username);

final EditText passwordET = (EditText)layout.findViewById(R.id.password);

builder.setTitle( 登录 ).setPositiveButton(确定), new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

// TODO Auto-generated method stub

Stringusername = userNameET.getText().toString();

String password = passwordET.getText().toString();

}

}).setNegativeButton("取消"), new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

// TODO Auto-generated method stub

}

});

builder.setView(layout);

AlertDialog ad = builder.create();

ad.show();

}

logindialog.xml

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

<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="match_parent"

android:layout_height="match_parent">

<TextView android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/username"

android:layout_weight="0.05"/>

<EditText android:id="@+id/username"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:background="@android:drawable/editbox_background"

android:layout_weight="0.04"/>

<TextView android:layout_width="fill_parent"

android:text="@string/password"

android:layout_height="wrap_content"

android:layout_weight="0.04"/>

<EditText android:id="@+id/password"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:inputType="textPassword"

android:background="@android:drawable/editbox_background"

android:layout_weight="0.04"/>

</LinearLayout>

赞助本站

人工智能实验室
AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港