为什么我得到无法解决类android中的方法错误?

时间:2015-06-22 08:01:48

标签: android json

我使用本教程:

JSON


和部分代码:

protected String doInBackground(String... urls) {

            TextView lbl=(TextView) findViewById(R.id.provCODE);
            person = new Person();
            person.setName(lbl.getText().toString());
            //person.setCountry("1853");
            //person.setTwitter("1892");


            return POST(urls[0],person);
        }


但在这一行:

person.setName(lbl.getText().toString());


我收到这个错误:

Can not resolve method.


我怎么能解决这个问题?会发生什么? 我的班级是:

public class Person {

        private String name;
        private String country;
        private String twitter;

//getters & setters....

    }

1 个答案:

答案 0 :(得分:0)

您没有在Person类中创建setName()方法。

public class Person {

    private String name;
    private String country;
    private String twitter;

    //getters & setters....
    public void setName(String pName) {
        this.name = pName;
    }

    public void getName() {
       return this.name;
    }
}