按钮,alert,EditText
activity_main XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="手机号" />
<EditText
android:id="@+id/edit_text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入手机号"
/>
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="手机号" />
<EditText
android:id="@+id/edit_text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入手机号"
/>
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="本机手机号" />
<EditText
android:id="@+id/edit_text3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入本机手机号"
/>
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="注册"
/>
</LinearLayout>
MainActivity:
public class MainActivity extends Activity implements OnClickListener{
private Button button;
private EditText editText1;
private EditText editText2;
private EditText editText3;
private ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1);
button=(Button) findViewById(R.id.button);
editText1=(EditText) findViewById(R.id.edit_text1);
editText2=(EditText) findViewById(R.id.edit_text2);
editText3=(EditText) findViewById(R.id.edit_text3);
button.setOnClickListener(this);
}
@Override
public void onClick(View v){
switch(v.getId()){
case R.id.button:
// 在此添加逻辑
AlertDialog.Builder dialog=new AlertDialog.Builder(MainActivity.this);
dialog.setTitle("打印");
String inputText1=editText1.getText().toString();
String inputText2=editText2.getText().toString();
String inputText3=editText3.getText().toString();
dialog.setMessage(inputText1+'\n'+inputText2+'\n'+inputText3);
dialog.show();
break;
default:
break;
}
}
}
- 用代码控制点击按钮添加EditText
- AlertDialog with edittext
- 自定义的AlertDialog里面点击EditText的时候软键盘不能弹出
- android AlertDialog中EditText无法显示软键盘问题的解决方案
- EditText弹出的软键盘带搜索按钮
- 一个带清除按钮的EditText-->ClearEditText
- EditText的输入法显示、隐藏和AlertDialog中的EditText无法调出输入法的问题
- 自定义View之自定义EditText带删除内容按钮控件
- LayoutInflater作用及使用--自定义EditText,自带清除内容按钮
- 关于在AlertDiaLog中的Edittext无法打开软键盘问题
- Android实现带有删除按钮的EditText示例代码
- 简单实现EditText右侧删除按钮
- AlertDialog里面的EditText无法弹出软键盘
- 轻松打造带删除按钮的输入框(EditText)
- ListView嵌套EditText和按钮简易Demo
- 自定义EditText:带清除按钮的EditText
- EditText点击的时候软键盘上出现搜索按钮
- Android EditText中通过drawabeRight等添加了清空按钮 如何给按钮添加点击事件?
- 长按按钮让EditText中的数字递增
- Android弹出式对话框AlertDialog中的EditText自动打开软键盘