简体   繁体   English

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

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

I am trying to pass this variable as a parameter for a http call to my php file that inserts it into a database.我试图将此变量作为 http 调用的参数传递给我的 php 文件,该文件将其插入到数据库中。 If I create strings and manually set it, everything works.如果我创建字符串并手动设置它,一切正常。 But when I try to use user input my app crashes.但是当我尝试使用用户输入时,我的应用程序崩溃了。 I am thinking I am having trouble storing user input from EditText into a string variable in c#.我想我无法将 EditText 中的用户输入存储到 c# 中的字符串变量中。 I read in java people use .getText().toString() but c# doesnt have getText().我在 java 中读到人们使用 .getText().toString() 但 c# 没有 getText()。 I have tried this:我试过这个:

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

I have also tried:我也试过:

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" />

Now in c# you should do something like this现在在 c# 中你应该做这样的事情

string str = edittext.text;

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

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