展会信息港展会大全

带输入框(EditText)的AlertDialog
来源:互联网   发布日期:2016-01-14 12:25:35   浏览:1624次  

导读:一、Main Class:public void search() { Builder dialog = new AlertDialog.Builder(this); LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)......

一、Main Class:

public void search() {

Builder dialog = new AlertDialog.Builder(this);

LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

LinearLayout layout = (LinearLayout)inflater.inflate(R.layout.dialogview, null);

dialog.setView(layout);

et_search = (EditText)layout.findViewById(R.id.searchC);

dialog.setPositiveButton("查找", new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {

String searchC = et_search.getText().toString();

Intent intent = new Intent();

Bundle bundle = new Bundle();

bundle.putString("search", searchC);

intent.putExtras(bundle);

intent.setClass(ViewResultActivity.this, SearchResult.class);

ViewResultActivity.this.startActivity(intent);

}

});

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

public void onClick(DialogInterface dialog, int which) {

}

});

dialog.show();

}

二、dialogview.xml

<?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">

<EditText

android:id="@+id/searchC"

styles="@style/edittext_style1"

android:layout_width="200px"

android:layout_height="wrap_content"

android:gravity="left"

/>

</LinearLayout>

赞助本站

人工智能实验室

相关热词: 输入框 EditText AlertDialog

AiLab云推荐
展开

热门栏目HotCates

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