0
**Switching from Kitkat 4.4.4 to Lollipop 5.1.1 and testing on 5.1.1 issues on some onclicklisteners and addonTextListeners** 

错误是:

java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法“void android.widget.EditText.addTextChangedListener(android.text.TextWatcher)”。不幸地关闭了设备

它在 Kitkat 版本的 android 上运行良好。

public class HomeFrag extends ListFragment  {

    static  TextView tv;
    public String Pass1;
    public String Result1;
    View rootView;
    private String getItem;
   // static ArrayAdapter<Restaurants> adapter;
    int clickCounter = 0;
    static ListView list;
    ArrayList<Restaurants> RestaurantsList;
    Restaurants[] rest;
    Collection r;
    List<Restaurants> list2;
    int j = 1;
    EditText inputSearch;

    private static String url = "http://cloudsolutions-llc.com/halal_lte/index.php/home/get_data";

    static ArrayList<HashMap<String, String>> VenderList;
    private static final String TAG_NAME = "v_tname";
    private static final String TAG_PHONE = "v_tphone";
    private static final String TAG_HALAL = "v_hwhalal";
    private static final String TAG_ALCOHOL = "v_alcohol";
    private static final String TAG_ID = "id";

    private ProgressDialog pDialog;
    static ListAdapter adapter;
    SqlHandler sqlHandler;
    VendorListAdapter contactListAdapter;
    static String status ;
    static String query ;
    Cursor c1;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        rootView = inflater.inflate(R.layout.fraghome, container, false);

        VenderList = new ArrayList<HashMap<String, String>>();


        setupSearchView();
        // populateListView();
        new GetContacts().execute();


        sqlHandler = new SqlHandler(getActivity());

        Cursor resultSet = sqlHandler.selectQuery("Select * from VENDOR_DATABASE " ) ;
        //where name "  + " LIKE  '%"+"st"+"%'") ;
enter code here

        inputSearch = (EditText) rootView.findViewById(R.id.searchView2);



        status = AdvanceSearch.status;
        String hamza =  query;

        System.out.println("Query is " + status);
        System.out.println("Query 2 is == " + hamza);

//Error shows here
       inputSearch.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void afterTextChanged(Editable s) {

               query = "SELECT * FROM VENDOR_DATABASE   where name "  + " LIKE  '%"+inputSearch.getText()+"%'";

                sqlHandler = new SqlHandler(getActivity());


                ((MainActivity) getActivity()).showList(query);


                System.out.println(inputSearch.getText().toString());

                TextView tv = (TextView) rootView.findViewById(R.id.textView);

            }
        });
4

0 回答 0