android,调试时出了个bug

图片说明

MainActivity.java

 package com.example.ch02_dialogdemo;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;


public class MainActivity extends Activity implements OnClickListener{
      private LinearLayout line;
      private View myLoginView=null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        LayoutInflater layoutInflater=LayoutInflater.from(this );
        myLoginView=layoutInflater.inflate(R.layout.login,line);
        Button button=(Button)findViewById(R.id.bt1);
        button.setOnClickListener(this);
    }

    @Override
    public void onClick(View v)
    {
       switch (v.getId())
       {
       case R.id.bt1:


AlertDialog alertDialog=new AlertDialog.Builder(this ).create();

alertDialog.setTitle("用户登录");
alertDialog.setView(myLoginView);
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE,"确定",listener);
alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE,"取消",liss);
alertDialog.show();
       break;
       default:break;
       }
    }

    DialogInterface.OnClickListener listener=new DialogInterface.OnClickListener()
    {
        public void onClick(DialogInterface  dialog,int which)
        {

        }
    };

    DialogInterface.OnClickListener liss=new DialogInterface.OnClickListener()
    {
        public void onClick(DialogInterface  dialog,int which)
        {
        }
    };


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }



    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

在你的onClick()方法里面有错,
图片说明
根据这个报错,应该是你的Dialog设置布局的时候出问题了,好好检查检查

oncreat里面的问题