我无法在android studio中修复的错误(An error that I am unable to fix in android studio)

编程入门 行业动态 更新时间:2024-10-27 05:35:14
我无法在android studio中修复的错误(An error that I am unable to fix in android studio)

我正在创建一个需要登录和注册的应用程序,但在编写应用程序时我遇到了一个错误(我是菜鸟)任何人都可以帮助它谢谢:)

基本的想法是将条目发送到登录请求页面,该页面使用Json将详细信息转发给php,Json通过DB进行验证但是如果需要请更多详细信息遇到此错误请注释以便我可以上传和回复。

I am creating a app which requires log in and register but while coding for the app I encountered a error (I am noob) can anyone please help with it Thanks :)

Basic idea is to send the entries to login request page which forwards the details to the php using Json which verifies with the DB but encountering this error any more details if needed please comment so that I can upload and reply.

最满意答案

从你的问题中说出来有点难,但是在你的Login类中,它正在add()方法中查找Request<T>类型的对象,但是你提供了LoginRequest (因此在第二张图片)。

要解决这个问题,你需要让你的类继承一个名为StringRequest的Request<T>类型:你需要有这样的东西:

public class LoginRequest extends StringRequest {

如果没有这个,该类隐式选择Object作为它的超类(就像所有java对象一样),它没有你提供的参数。

那么,你有以下代码:

LoginRequest loginRequest = new LoginRequest(Email_id, Password, responseListener); RequestQueue queue = Volley.newRequestQueue(Login.this); queue.add(loginRequest);

RequestQueue的方法add()接受Request<T> 类型的参数。 LoginRequest 不是 Request<T> 。 这是你的错误的原因。 LoginRequest 需要从StringRequest继承。 这将解决这两个错误。 如果LoginRequest继承自StringRequest ,那么它是一个 Request<T> ,然后RequestQueue的方法add()可以除了loginRequest作为参数。

It's somewhat hard to tell from your question, but it looks like in your Login class, it is looking for an object of type Request<T> in the add() method, but you supplied it with LoginRequest (hence the error message in the second image).

To solve this problem, you need to make your class inherit from a type of Request<T> called StringRequest: you need to have something like this:

public class LoginRequest extends StringRequest {

Without this, the class implicitly chooses Object as it's super class (as all java objects do), which doesn't have the parameters you supplied.

So, where you have the following code:

LoginRequest loginRequest = new LoginRequest(Email_id, Password, responseListener); RequestQueue queue = Volley.newRequestQueue(Login.this); queue.add(loginRequest);

RequestQueue's method add() takes a parameter of type Request<T>. LoginRequest is not a Request<T>. This is the reason for your error. LoginRequest needs to inherit from StringRequest. This will fix both errors. If LoginRequest inherits from StringRequest, then it is-a Request<T> and then RequestQueue's method add() can except loginRequest as a parameter.

更多推荐

本文发布于:2023-08-04 17:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1420897.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   studio   android   fix   unable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!