开发者

How to Retrieve Text from Textbox in Android widget?

开发者 https://www.devze.com 2023-01-14 11:34 出处:网络
I\'m at the very early stage of learning Android. Can anyone tell me how I can use the text written in a Text box by user?

I'm at the very early stage of learning Android. Can anyone tell me how I can use the text written in a Text box by user?

I'm trying to use 开发者_高级运维getText() method but finding it confusing.

Thanks in advance.


getText should do it.

you maybe need a string cast?

what is the code you using @ the moment?

example:

EditText editText = (EditText)findViewById(R.id.yourId);

String editTextStr = editText.getText().toString()

docs:

http://developer.android.com/reference/android/widget/TextView.html#getText(


TextBox t = (TextBox)findViewById(R.id.textboxid)
String s = "";
s = t.getText().toString();

Here you can get content of textbox


I think what might be confusing him is that getText() doesn't return a string. You have to do getText().toString()


i think you are looking for TextView

http://developer.android.com/reference/android/widget/EditText.html

getText and setText methods are avaialbe in this class to set and get text value.


yes you need to retrieve the text by using getText() method. What is it that you find confusing here?

In short you need to say Textview.getText()

0

精彩评论

暂无评论...
验证码 换一张
取 消