大连249建站之家免费精品网站自助建设系统平台免费微
首页 >> 技术分享 >>技术干货 >> 249建站之家:android studio学习笔记--取得Edittext里的文字
详细内容

249建站之家:android studio学习笔记--取得Edittext里的文字

前台元素效果:


<EditText


        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:inputType="textPersonName"


        android:hint="请输入字母或数据"

        android:ems="10"

        android:layout_below="@+id/textView"

        android:layout_alignParentLeft="true"

        android:layout_alignParentStart="true"

        android:layout_marginTop="12dp"

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


    <Button

        android:text="提交"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignTop="@+id/editText_ana"

        android:layout_alignParentRight="true"

        android:layout_alignParentEnd="true"

        android:layout_marginRight="21dp"

        android:layout_marginEnd="21dp"

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


代码效果:


@Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_indexmodify);

        /////////////////////////////////////////////////////////

        Button bana = (Button) findViewById(R.id.button_ana);

        bana.setOnClickListener(new View.OnClickListener(){

            @Override

            public void onClick(View v){

                EditText etext = (EditText) findViewById(R.id.editText_ana);

                String utext = etext.getText().toString();

                Toast.makeText(indexmodify.this,utext,Toast.LENGTH_LONG).show();

            }

        });

        /////////////////////////////////////////////////////////


    }


联系我们
更多

联系电话:0411-66373325

联系地址:大连市沙河口区富民广场

公司邮箱:2058793689@qq.com

备案信息:Copyright © 2016-2025,www.my249.com,All rights reserved

辽ICP备17015910号-1

seo seo