Java 选定id后,应用程序强制停止

Java 选定id后,应用程序强制停止,java,android,listview,Java,Android,Listview,嗨,伙计们,我只是想请求我的应用程序的帮助,每当我选择一个id时,它的强制停止,它显示错误在我的字符串中,但我没有看到任何错误,它告诉我错误在final String user=etinput.getText.toString;上;。这是我的密码 ArrayList<Messages> list; MessageDatabase mydb; MessageAdapter adapter = null; @Override protected void onCreate(Bundle

嗨,伙计们,我只是想请求我的应用程序的帮助,每当我选择一个id时,它的强制停止,它显示错误在我的字符串中,但我没有看到任何错误,它告诉我错误在final String user=etinput.getText.toString;上;。这是我的密码

ArrayList<Messages> list;
MessageDatabase mydb;
MessageAdapter adapter = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_list_message);
    listv = (ListView) findViewById(R.id.lv);
    registerForContextMenu(listv);
    add = (FloatingActionButton) findViewById(R.id.fabadd);
    fbnew = (FloatingActionButton) findViewById(R.id.fabnew);
    fbedit = (FloatingActionButton) findViewById(R.id.fabedit);
    fbdelete = (FloatingActionButton) findViewById(R.id.fabdelete);
    add = (FloatingActionButton) findViewById(R.id.fabadd);
    backlist = (ImageButton) findViewById(R.id.imgbacklist);

    rotateplus = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.fabplus);
    clockplus = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.fabplusclose);
    fabopen = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.fab_open);
    fabclose = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.fab_close);


    add.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
         if(open){

             add.startAnimation(clockplus);
             fbnew.startAnimation(fabclose);
             fbedit.startAnimation(fabclose);
             fbdelete.startAnimation(fabclose);
             fbnew.setClickable(false);
             fbedit.setClickable(false);
             fbdelete.setClickable(false);

             open = false;
         }
         else{
            add.startAnimation(rotateplus);
             fbnew.startAnimation(fabopen);
             fbedit.startAnimation(fabopen);
             fbdelete.startAnimation(fabopen);
             fbnew.setClickable(true);
             fbedit.setClickable(true);
             fbdelete.setClickable(true);

             open = true;

             fbnew.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     Intent i = new Intent(ListMessage.this,AddActivity.class);
                     startActivity(i);
                     finish();
                 }

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

                     alert();

                 }
             });
             fbedit.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     LayoutInflater lay = getLayoutInflater();
                     viewlayout = lay.inflate(R.layout.input, (ViewGroup) findViewById(R.id.layoutinput));
                     AlertDialog.Builder b = new AlertDialog.Builder(ListMessage.this);
                     b.setTitle("Enter the MSG ID you want to edit");
                     b.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                         @Override
                         public void onClick(DialogInterface dialogInterface, int i) {

                             EditText etinput = (EditText) findViewById(R.id.edtinput);



                             Intent a = new Intent(ListMessage.this,UpdateActivity.class);

                             startActivity(a);
                             finish();

                         }
                     });
                     b.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                         @Override
                         public void onClick(DialogInterface dialogInterface, int i) {
                             dialogInterface.cancel();
                         }
                     });
                     b.setView(viewlayout);
                     AlertDialog alert = b.create();
                     alert.show();

                 }
             });
         }
        }
    });


    backlist.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });

    mydb = new MessageDatabase(this, "MDB.sqlite", null, 1);

    list = new ArrayList<Messages>();
    adapter = new MessageAdapter(this, R.layout.messages, list);
    listv.setAdapter(adapter);


    Cursor cursor = SecondActivity.mydb.getData("SELECT * FROM MDB ");
    list.clear();
    while (cursor.moveToNext()) {


        int id = cursor.getInt(0);


        String frm = cursor.getString(1);
        String to = cursor.getString(2);

        String msg = cursor.getString(3);

        list.add(new Messages(id, frm, to, msg));

    }
    adapter.notifyDataSetChanged();

}





private void editt() {



}


private void alert() {

    LayoutInflater lay = getLayoutInflater();
    viewlayout = lay.inflate(R.layout.input, (ViewGroup) findViewById(R.id.layoutinput));
    EditText etinput = (EditText) findViewById(R.id.edtinput);
    final String user = etinput.getText().toString();

   AlertDialog.Builder b = new AlertDialog.Builder(ListMessage.this);
    b.setTitle("Enter the MSG ID you want to delete");
    b.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {

            Integer rows = mydb.deleteData(user);
            if (rows > 0) {
                Toast.makeText(getApplicationContext(), "Done...", Toast.LENGTH_LONG).show();
                Intent a = new Intent(ListMessage.this,ListMessage.class);
                startActivity(a);
                finish();

            } else {
                Toast.makeText(getApplicationContext(), "Delete Failed...", Toast.LENGTH_LONG).show();
            }


        }
    });
            b.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.cancel();
                }
            });
    b.setView(viewlayout);

    AlertDialog alert = b.create();
    alert.show();

}
把你的

EditText etinput = (EditText) findViewById(R.id.edtinput);
在onCreate中,并使所有类都可以访问它

或者如果它是来自另一个视图的编辑文本

EditText etinput = (EditText) view.findViewById(R.id.edtinput);

在问题中张贴完整的崩溃日志。最有可能的是您的输入为空。发布xml文件。您可能希望查看layout.findviewbydr.id.input