当我运行它时,应用程序立即崩溃

时间:2016-02-05 23:10:41

标签: android

我正在尝试构建一个基本的Android应用程序,一旦应用程序运行就会出现注册表单, 当我在模拟器上运行时它会崩溃 这是我的代码

on main在主

中创建代码
require 'watir-webdriver'
b = Watir::Browser.new 
b.goto('http://imgur.com/')

b.span(text: "upload images").click

# alternately:
# b.div(class: "selection icon icon-arrow-down").click
# b.link(text: "Upload Images").click

这是控制台日志

这里显示的问题是onClockListenr试图调用

  protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.signup);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        tv1 = (TextView) findViewById(R.id.textView1);
        tv2 = (TextView) findViewById(R.id.textView2);
        tv3 = (TextView) findViewById(R.id.textView3);

        et1 = (EditText) findViewById(R.id.email);
        et2 = (EditText) findViewById(R.id.name);
        et3 = (EditText) findViewById(R.id.password);

        submit = (Button) findViewById(R.id.register);

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

                String email = et1.getText().toString();
                String name = et2.getText().toString();
                String password = et3.getText().toString();

                //Some code running
            }
        });

signup.xml文件中的Button属性

02-05 18:11:46.275 2121-2121/? E/AndroidRuntime: FATAL EXCEPTION: main
                                             Process: com.example.mazinalmaskari.twitter, PID: 2121
                                             java.lang.RuntimeException: Unable to start activity 

ComponentInfo{com.example.mazinalmaskari.twitter/com.example.mazinalmaskari.twitter.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference

为什么应用程序崩溃-_-

0 个答案:

没有答案