What's wrong in this simple android Program, I get 'Force Close'.

Posted by andyfan on Stack Overflow See other posts from Stack Overflow or by andyfan
Published on 2011-01-11T08:41:59Z Indexed on 2011/01/11 8:53 UTC
Read the original article Hit count: 181

Filed under:
|

What is wrong in this program, My eclipse IDE doesn't show any errors....when I execute this simple program the emulator shows force close....Anybody please clarify

import android.app.Activity;
import android.view.View.OnClickListener;
import android.view.View;
import android.os.Bundle;
import android.widget.*;

public class HelloWorld extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
    View Et1,Bt1,TxtDisp;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.name_getter);
        Bt1=(Button)findViewById(R.id.Btn1);
        Et1=(EditText)findViewById(R.id.UserInput);
        TxtDisp=(TextView)findViewById(R.id.TextDisp);
        Bt1.setOnClickListener(this);      
    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        String userInput=((EditText) Et1).getText().toString();
        ((TextView)TxtDisp).setText(userInput);
    }
}

© Stack Overflow or respective owner

Related posts about android

Related posts about error