android.view.InflateException: Binary XML file line #30: Error inflating class <unknown>

こ雲淡風輕ζ 提交于 2019-12-04 14:12:00
Metalhead1247

Instead of calling

     View view = getLayoutInflater().inflate(R.layout.dialogview, null);
     view.setBackgroundColor(Color.LTGRAY);
     dialog.setContentView(view);

remove above lines and try adding this to your code

  dialog.setContentView(R.layout.dialogview);

  public boolean onMarkerClick(Marker arg0) {

  Log.d("", "here");
  dialog.setContentView(R.layout.dialogview);
  edtDate = (TextView) findViewById(R.id.edtDate);

  edtTime = (TextView) findViewById(R.id.edtTime);

  Dialog dialog = new Dialog(this,
        android.R.style.TextAppearance_Holo_WindowTitle);
  dialog.setTitle("Enter Details");
  LayoutParams lp = dialog.getWindow().getAttributes();
  lp.width = WindowManager.LayoutParams.MATCH_PARENT;
  lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
  lp.gravity = Gravity.TOP | Gravity.LEFT;
  lp.dimAmount = 0;
  lp.flags = LayoutParams.FLAG_LAYOUT_NO_LIMITS
        | LayoutParams.FLAG_NOT_TOUCH_MODAL;

  Spinner ddlspinnerdata = (Spinner) view.findViewById(R.id.ddl);
  ddldata = ddlspinnerdata.getSelectedItem().toString();
  EditText edtname = (EditText) view.findViewById(R.id.personname);
  name = edtname.getText().toString();
  EditText edtLength = (EditText) view.findViewById(R.id.edtlength);
  length = edtLength.getText().toString();
  EditText edtWidth = (EditText) view.findViewById(R.id.edtwidth);
  width = edtWidth.getText().toString();
  EditText edtHeight = (EditText) view.findViewById(R.id.edtheight);
  height = edtHeight.getText().toString();
  date = edtDate.getText().toString();
  time = edtTime.getText().toString();


dialog.show();
     }

why are you set wrap content for request focus i think this is giving you exception

<requestFocus android:layout_width="wrap_content" />  

just add <requestFocus/> if not try to remove this line and check once some styles are gives you inflater exceptions..

style="?android:attr/buttonStyleSmall"
// try this code
        final Dialog dialog = new Dialog(this);
        dialog.setTitle("Enter Details");
        dialog.setContentView(R.layout.main);

        Button btnsave = (Button) dialog.findViewById(R.id.btnsave);
        Button btncancel = (Button) dialog.findViewById(R.id.btncancel);
        final Spinner ddlspinnerdata = (Spinner) dialog.findViewById(R.id.ddl);
        final EditText edtname = (EditText) dialog.findViewById(R.id.personname);
        final EditText edtLength = (EditText) dialog.findViewById(R.id.edtlength);
        final EditText edtWidth = (EditText) dialog.findViewById(R.id.edtwidth);
        final EditText edtHeight = (EditText) dialog.findViewById(R.id.edtheight);
        final TextView edtDate = (TextView) dialog.findViewById(R.id.edtDate);
        final TextView edtTime = (TextView) dialog.findViewById(R.id.edtTime);

        btncancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });

        btnsave.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ddldata = ddlspinnerdata.getSelectedItem().toString();
                name = edtname.getText().toString();
                length = edtLength.getText().toString();
                width = edtWidth.getText().toString();
                height = edtHeight.getText().toString();
                date = edtDate.getText().toString();
                time = edtTime.getText().toString();
                dialog.dismiss();
            }
        });
        dialog.show();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!