Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Android:第二个私有类不在本地使用_Php_Android_Json - Fatal编程技术网

Php Android:第二个私有类不在本地使用

Php Android:第二个私有类不在本地使用,php,android,json,Php,Android,Json,我用两种方法制作了一个android类,一种是在listview中显示数据库内容,另一种是在文本视图中显示数据库条目。第二个不起作用 代码片段 private String url = "http://10.0.3.2/sunshine-ems/leavelist.php"; private String url2 = "http://10.0.3.2/sunshine-ems/leavebal.php"; 首先 这是一个不起作用的它说DownloadStylest不是本地使用的 privat

我用两种方法制作了一个android类,一种是在listview中显示数据库内容,另一种是在文本视图中显示数据库条目。第二个不起作用

代码片段

private String url = "http://10.0.3.2/sunshine-ems/leavelist.php";
private String url2 = "http://10.0.3.2/sunshine-ems/leavebal.php";
首先

这是一个不起作用的它说DownloadStylest不是本地使用的

private class DownloadStylist extends AsyncTask<String, String, JSONObject> {
        private ProgressDialog progressDialog = new ProgressDialog(
                Leavelist.this);

        protected void onPreExecute() {

            progressDialog.setMessage("Loading profile ...");
            progressDialog.setIndeterminate(false);
            progressDialog.setCancelable(false);
            progressDialog.show();

        }

        protected JSONObject doInBackground(String... args) {


            username = session.getUsername();

            List<NameValuePair> params1 = new ArrayList<NameValuePair>();
            params1.add(new BasicNameValuePair("username", username));


            JSONObject json = jsonParser.makeHttpRequest(url2, "POST", params1);

            // Check your log cat for JSON reponse
            Log.d("Profile JSON: ", json.toString());

            try {
                // profile json object
                jsonarray = json.getJSONArray("user");
                user = new String[jsonarray.length()];
                for (int m = 0; m < jsonarray.length(); m++) {

                    json = jsonarray.getJSONObject(m);

                    // Retrive JSON Objects
                    user[m] = json.getString("user");

                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return json;
        }

        @Override
        protected void onPostExecute(JSONObject json) {
            super.onPostExecute(json);
            // dismiss the dialog after getting all products
            progressDialog.dismiss();
            try {

                String sick_leave = json.getString("sick_leave");


                // displaying all data in textview
                leavebal.setText(sick_leave);



            } catch (Exception e) {
                e.printStackTrace();
            }

        }

    }

您已经声明了类,但从未实例化并调用它,因为它是私有的,您将得到该警告。

您已经声明了类,但从未实例化并调用它,因为它是私有的,您将得到该警告。哦,我的天哪。这样一个基本的错误,哈哈哈,是的,它做到了
private class DownloadStylist extends AsyncTask<String, String, JSONObject> {
        private ProgressDialog progressDialog = new ProgressDialog(
                Leavelist.this);

        protected void onPreExecute() {

            progressDialog.setMessage("Loading profile ...");
            progressDialog.setIndeterminate(false);
            progressDialog.setCancelable(false);
            progressDialog.show();

        }

        protected JSONObject doInBackground(String... args) {


            username = session.getUsername();

            List<NameValuePair> params1 = new ArrayList<NameValuePair>();
            params1.add(new BasicNameValuePair("username", username));


            JSONObject json = jsonParser.makeHttpRequest(url2, "POST", params1);

            // Check your log cat for JSON reponse
            Log.d("Profile JSON: ", json.toString());

            try {
                // profile json object
                jsonarray = json.getJSONArray("user");
                user = new String[jsonarray.length()];
                for (int m = 0; m < jsonarray.length(); m++) {

                    json = jsonarray.getJSONObject(m);

                    // Retrive JSON Objects
                    user[m] = json.getString("user");

                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return json;
        }

        @Override
        protected void onPostExecute(JSONObject json) {
            super.onPostExecute(json);
            // dismiss the dialog after getting all products
            progressDialog.dismiss();
            try {

                String sick_leave = json.getString("sick_leave");


                // displaying all data in textview
                leavebal.setText(sick_leave);



            } catch (Exception e) {
                e.printStackTrace();
            }

        }

    }