0

LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

我正在使用 getSystemService() 但是,我正在使用“方法 getSystemService(String) 未定义为 CustomAdapter 类型”错误

使用什么来代替 getSystemService 或任何其他解决方案?

4

3 回答 3

1

你可以制作这样的适配器

public CustomAdapter(YourActivtyName context) {

    LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
于 2013-07-04T07:03:31.833 回答
0
LayoutInflater vi = (LayoutInflater) YourEnclosingActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
于 2013-07-04T06:58:30.257 回答
0

尝试这个 :

LayoutInflater vi = (LayoutInflater)YourClassName.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

或者 :

LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

context类的对象在哪里Context

于 2013-07-04T07:33:01.607 回答