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


Android: Second Private class is not used locally

我正在用两种方法制作一个 android 类,一种是将数据库内容显示到列表视图中,一种是简单地在文本视图上显示数据库条目。第二个不起作用

代码片段

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

第一

private class DownloadJSON extends AsyncTask<String, String, String> {
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            mProgressDialog = new ProgressDialog(Leavelist.this);
            mProgressDialog.setTitle("Loading Services");
            mProgressDialog.setMessage("Loading...");
            mProgressDialog.setIndeterminate(false);
            mProgressDialog.show();
        }
        @Override
        protected String doInBackground(String... params) {
            username = session.getUsername();
            List<NameValuePair> params1 = new ArrayList<NameValuePair>();
            params1.add(new BasicNameValuePair("username", username));
            JSONObject json = jsonParser.makeHttpRequest(url, "POST", params1);
            // Check your log cat for JSON reponse
            Log.d("Check JSON ", json.toString());
            // Create the array
            arraylist = new ArrayList<HashMap<String, String>>();
            try {
                // Locate the array name
                jsonarray = json.getJSONArray("leavelist");
                for (int i = 0; i < jsonarray.length(); i++) {
                    HashMap<String, String> map = new HashMap<String, String>();
                    json = jsonarray.getJSONObject(i);
                    String l_id = json.getString(LEAVE_ID);
                    String l_type = json.getString(LEAVE_TYPE);
                    String l_stat = json.getString(LEAVE_STAT);
                    // Retrive JSON Objects
                    map.put(LEAVE_STAT, l_stat);
                    map.put(LEAVE_TYPE, l_type);
                    map.put(LEAVE_ID, l_id);
                    // Set the JSON Objects into the array
                    arraylist.add(map);
                }
            } catch (JSONException e) {
                Log.e("Error", e.getMessage());
                e.printStackTrace();
            }
            return null;
        }
        @Override
        protected void onPostExecute(String file_url) {
            mProgressDialog.dismiss();
            // updating UI from Background Thread
            runOnUiThread(new Runnable() {
                public void run() {
                    /**
                     * Updating parsed JSON data into ListView
                     * */
                    ListAdapter adapter = new SimpleAdapter(
                            Leavelist.this,
                            arraylist,
                            R.layout.listview_services,
                            new String[] { LEAVE_ID, LEAVE_TYPE, LEAVE_STAT },
                            new int[] { R.id.transac_id, R.id.txt_service,
                                    R.id.txt_date });
                    // updating listview
                    setListAdapter(adapter);
                }
            });
        }
    }

这是不起作用的那个,它说"下载造型师未在本地使用"

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();
            }
        }
    }

您已经声明了该类,但从未实例化和调用它,并且由于它是私有的,因此您将收到该警告。