由网友(承蒙喜欢)分享简介:我学习如何创建UI元素。我已经创建了一些的EditText输入字段。一个按钮的点击我想捕捉输入到该输入字段的内容。I am learning how to create UI elements. I have created a few EditText input fields. On the click of a...
我学习如何创建UI元素。我已经创建了一些的EditText输入字段。一个按钮的点击我想捕捉输入到该输入字段的内容。
I am learning how to create UI elements. I have created a few EditText input fields. On the click of a Button I want to capture the content typed into that input field.
<EditText android:id="@+id/name" android:width="220px" />
这是我的领域。我怎样才能得到的内容?
That's my field. How can I get the content?
推荐答案
通过使用gettext():
By using getText():
Button mButton;
EditText mEdit;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mButton = (Button)findViewById(R.id.button);
mEdit = (EditText)findViewById(R.id.edittext);
mButton.setOnClickListener(
new View.OnClickListener()
{
public void onClick(View view)
{
Log.v("EditText", mEdit.getText().toString());
}
});
}
相关推荐
最新文章