【问题标题】:Passing Edittext value to Get Request URL in Volley在 Volley 中传递 Edittext 值以获取请求 URL
【发布时间】:2019-09-22 00:44:20
【问题描述】:

我想在 Android 中将 edittext 值添加到简单的 GET 请求 URL。但是我在连接时遇到了一些错误。这就是我要发送的。

String forgot_email = et_email.getText().toString(); //gives me proper email output

final String final_url = "http:abc....../"+forgot_email.getText().toString(); // Here edittext value is not appending. 

final_url = "http:abc....../" // logs value shows its not appending in the end.  

我想将此 URL 发送到服务器。

http:abc....../EMailID

我们将不胜感激任何回复。

【问题讨论】:

  • 应该是 String final_url = "http:abc....../"+ et_email.getText().toString();et_email 而不是 forgot_email
  • @elbertrivas 那行不通。显示日志值
  • @jeetdeveloper 尝试从您的字符串中删除 final 并检查 url 的日志。
  • @Ashish 没有最后的凌空抽射没有进一步进行.. 根据日志的 url 值是 http:abc....../
  • 你使用的是什么网络库?

标签: android string android-volley string-concatenation


【解决方案1】:

我解决了。基本上我在点击监听器里面写了这两行。我之前在外面写过。谢谢大家

【讨论】:

  • 所以你应该接受你自己的答案作为正确的答案。这是 SO 中的最佳实践,并且通过提醒他们问题未解决来使未来的用户受益。谢谢。
  • 是的。谢谢你的答复。它说你明天可以强调自己的答案,所以我明天会做。问候
【解决方案2】:

应该是

String final_url = "http:abc....../"+et_email.getText().toString();

String final_url = "http:abc....../"+ forgot_email;

【讨论】:

  • 两种方式都试过了。我收到这个错误。 D/VolleyERRORResponse: com.android.volley.ServerError edittext 值未附加在末尾。根据日志
  • e E/Volley: [468] BasicNetwork.performRequest: http:abc 的意外响应代码 405 ......// 这是日志
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-08-29
  • 2023-03-21
  • 2015-09-22
  • 1970-01-01
  • 2022-11-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多