无法解析方法' setText(java.lang.String

时间:2017-05-16 20:26:21

标签: java android

我正在尝试添加一个名为smooth check box的库,而我试图将其强制转换它向我显示错误无法解析方法' setText(java.lang.String' 这是我的班级 .................................................. ..........................

package abtech.waiteriano.com.retrievingcontactsexample;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import cn.refactor.library.SmoothCheckBox;

/**
 * Created by Trinity Tuts on 10-01-2015.
 */
public class SelectUserAdapter extends BaseAdapter {

    public List<SelectUser> _data;
    private ArrayList<SelectUser> arraylist;
    Context _c;
    ViewHolder v;

    public SelectUserAdapter(List<SelectUser> selectUsers, Context context) {
        _data = selectUsers;
        _c = context;
        this.arraylist = new ArrayList<SelectUser>();
        this.arraylist.addAll(_data);
    }

    @Override
    public int getCount() {
        return _data.size();
    }

    @Override
    public Object getItem(int i) {
        return _data.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {
        View view = convertView;
        if (view == null) {
            LayoutInflater li = (LayoutInflater) _c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = li.inflate(R.layout.contact_list_item, null);
            Log.e("Inside", "here--------------------------- In view1");
        } else {
            view = convertView;
            Log.e("Inside", "here--------------------------- In view2");
        }

        v = new ViewHolder();

        v.check = (SmoothCheckBox) view.findViewById(R.id.contactsCB);

        final SelectUser data = (SelectUser) _data.get(i);
        v.check.setText(data.getName());
        v.check.setChecked(data.getCheckedBox());;


        Log.e("Image Thumb", "--------------" + data.getThumb());

        /*// Set check box listener android
        v.check.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                CheckBox checkBox = (CheckBox) view;
                if (checkBox.isChecked()) {
                    data.setCheckedBox(true);
                  } else {
                    data.setCheckedBox(false);
                }
            }
        });*/

        view.setTag(data);
        return view;
    }

    // Filter Class
    public void filter(String charText) {
        charText = charText.toLowerCase(Locale.getDefault());
        _data.clear();
        if (charText.length() == 0) {
            _data.addAll(arraylist);
        } else {
            for (SelectUser wp : arraylist) {
                if (wp.getName().toLowerCase(Locale.getDefault())
                        .contains(charText)) {
                    _data.add(wp);
                }
            }
        }
        notifyDataSetChanged();
    }
    static class ViewHolder {
        SmoothCheckBox check;
    }
}

以及此行中的错误

v.check.setText(data.getName());

android监视器错误

Information:Gradle tasks [:app:assembleDebug]
E:\AndroidWorkSpace\RetrievingContactsExample\app\src\main\java\abtech\waiteriano\com\retrievingcontactsexample\SelectUserAdapter.java
Error:(69, 16) error: cannot find symbol method setText(String)
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 1.206 secs
Information:2 errors
Information:0 warnings
Information:See complete output in console

............................................... ............................. 我不知道如何解决这个错误,如果有任何可以帮助我的话,我很高兴 抱歉任何事情都不清楚我希望这会是可以理解的 .................................................. ..........................

1 个答案:

答案 0 :(得分:1)

我认为你的意思是this SmoothCheckBox on github

查看source code,找不到setText(String) - 方法。如果我正确理解自述文件,那些复选框的设计选择和未选择颜色,但没有文字。