Android – unfortunately appName has stopped the error

When I run my application according to the error message, it gives:

I have the following mainactivity.java file:

package com.example.hello_world;

import android.os.Bundle;
import android.app.Activity;
import android.app.Dialog;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedchangelistener;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;
import android.view.View.OnClickListener;  

public class MainActivity extends Activity implements  OnCheckedchangelistener {

    Button btnSubmit,b2;
    RadioButton rb1,rb2;
    EditText etFirstName,etLastName;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        btnSubmit=(Button)findViewById(R.id.btnSubmit);


        rb1.setOnCheckedchangelistener(new OnCheckedchangelistener()  {





        btnSubmit.setOnClickListener(new OnClickListener()
        {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub


                    switch(v.getId())
                    {
                    case R.id.btnSubmit:

                        boolean didWork=true;
                        try
                        {
                        String fName=((EditText) findViewById(R.id.etFirstName)).getText().toString();
                        String LName=((EditText) findViewById(R.id.etLastNam)).getText().toString();


                        Toast msg1 = Toast.makeText(getBaseContext(),
                                fName, Toast.LENGTH_LONG);
                      msg1.show();

                        HNT entry=new HNT(MainActivity.this);

                        entry.open();


                        Toast msg2 = Toast.makeText(getBaseContext(),
                                fName, Toast.LENGTH_LONG);
                         msg2.show();

                        entry.createEntry(fName,LName);


                        entry.close();

                        break;
                        }
                        catch(Exception e)
                        {
                            didWork=false;


                            Toast msg1 = Toast.makeText(getBaseContext(),
                                    "Catch Failed"+e.getMessage(), Toast.LENGTH_LONG);
                          msg1.show();

                        }
                        finally
                        {
                            if(didWork)
                            {
                                Toast msg1 = Toast.makeText(getBaseContext(),
                                        "Sucess", Toast.LENGTH_LONG);
                              msg1.show();


                            }
                            else
                            {
                                Toast msg1 = Toast.makeText(getBaseContext(),
                                        "Failed", Toast.LENGTH_LONG);
                              msg1.show();
                            }
                        }

                }



            }
        });        
 }


    @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 void onCheckedChanged(CompoundButton arg0, boolean arg1) {
        // TODO Auto-generated method stub

    }

}
@H_419_14@

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>