无法在android中的列表项前面出现对话框

时间:2017-01-06 07:50:26

标签: android listview dialog

我有ListView,其中每个列表项都像一张卡片,一旦点击,就会显示一个对话框。但我的问题是,它在智能手机上完美运行,但在平板电脑上却无法运行。我希望对话框显示在卡片的中央,但它显示在卡片下方。

我有一个对话框类,我在点击TextView时调用了它。

代码 //适配器代码

viewHolder.customerName.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            getCustomerProfile(order_id, mContext);
        }
    });


   public void getCustomerProfile(final String orderid, Context context) {

    new GetCustomerData().execute(new Config().userProfile, orderid);



}


    public class GetCustomerData extends AsyncTask<String, Integer, String> {


    @Override
    protected String doInBackground(String... params) {
        try {
            String link = (String) params[0];
            String id = (String) params[1];
            String data = URLEncoder.encode("orderid", "UTF-8") + "=" + URLEncoder.encode(id, "UTF-8");
            URL url = new URL(link);
            URLConnection conn = url.openConnection();
            conn.setDoOutput(true);
            OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
            wr.write(data);
            wr.flush();
            BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            StringBuilder sb = new StringBuilder();
            String line = null;

            //Read Server Response
            while ((line = reader.readLine()) != null) {
                sb.append(line);
                break;
            }
            return sb.toString();
        } catch (Exception e) {
            return new String("Exception : " + e.getMessage());
        }
    }


    protected void onPostExecute(String s) {

        if (!s.equals("exception")) {
            try {
                JSONObject obj = new JSONObject(s);
                JSONObject object = obj.getJSONObject("result");


                name = object.getString("name");
                number = object.getString("mobile");
                if (object.getString("pic").length() > 0) {
                    pic = new Config().profilepiclink + object.getString("pic");
                } else
                    pic = "http://trackback.net/wp-content/uploads/2015/02/Dummy-profile-picture.png";


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

        }

        Dialog_Call_User dc = new Dialog_Call_User((Activity) mContext,name, pic, number, mContext);

        dc.getWindow().setLayout(width / 2, height / 2);
        dc.show();

    }


}

现在我在卡片底部而不是在中心放置了dilaod的问题的截图

http://prntscr.com/ds4iwx

1 个答案:

答案 0 :(得分:0)

我认为你的自定义布局对话框是个问题。