[英]Convert value from edit text to byte
i've searched a lot now, but i didn't find anything, so i'll ask here. 我已经搜索了很多东西,但是我什么都没找到,所以我在这里问。 This is the code i've got a the moment: 这是我花了一会儿的代码:
byte[] valueofet = (EditText)findViewById(R.id.edittext1);
String base64 = Base64.encodeToString(valueofet, Base64.DEFAULT);
The error Eclipse is giving me: Eclipse给我的错误:
Type mismatch: cannot convert from EditText to byte[]
Can you help me? 你能帮助我吗?
Hmm, it seems you're new to JAVA as well. 嗯,看来您也是JAVA的新手。
Use: 采用:
EditText myEditText = (EditText)findViewById(R.id.edittext1);
String content = myEditText.getText().toString();
Use this one:- 使用这个:
EditText valueofet = (EditText)findViewById(R.id.edittext1);
String value=valueofet.getText().toString();
String base64 = Base64.encodeToString(value, Base64.DEFAULT);
cheers....! 干杯....! Please let me know if it works or not...!! 请让我知道它是否有效... !!
Here we go... 开始了...
EditText valueofet = (EditText)findViewById(R.id.edittext1);
Byte[] value=valueofet.getText().toString().getBytes();
String base64 = Base64.encodeToString(value, Base64.DEFAULT);
I know I am late, but for now It should like this: 我知道我迟到了,但是现在它应该像这样:
EditText valueofet = (EditText)findViewById(R.id.edittext1);
byte myByte = Byte.parseByte(valueofet.getText().toString());
Try this 尝试这个
myEditText.getString().getBytes(); myEditText.getString()的getBytes();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.