繁体   English   中英

如何将EditText用户输入存储到c#中的字符串变量中

[英]how to store EditText user input into a string variable in c#

我试图将此变量作为 http 调用的参数传递给我的 php 文件,该文件将其插入到数据库中。 如果我创建字符串并手动设置它,一切正常。 但是当我尝试使用用户输入时,我的应用程序崩溃了。 我想我无法将 EditText 中的用户输入存储到 c# 中的字符串变量中。 我在 java 中读到人们使用 .getText().toString() 但 c# 没有 getText()。 我试过这个:

EditText usernameText = FindViewById<EditText>(Resource.Id.editUsername);
string username = usernameText.Text; 

我也试过:

string username = usernameText.toString();
<EditText
    android:id="@+id/edittext"
    android:layout_width="match_parent"
    android:imeOptions="actionGo"
    android:inputType="text"
    android:layout_height="wrap_content" />

现在在 c# 中你应该做这样的事情

string str = edittext.text;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM