我无法理解问题出在哪里,并且无法执行应用程序
进一步他们是我的代码
代码:pass1:-
public class Pass1 extends Activity {
EditText pno=(EditText)findViewById(R.id.editText1);
Button btn=(Button)findViewById(R.id.button1);
String pn=pno.getText().toString();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pass1);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(pn.charAt(0)=='9' || pn.charAt(0)=='8' || pn.charAt(0)=='7')
{
if (pno.getText().toString().length()==10)
{
Intent i= new Intent(Pass1.this, Pass2.class);
i.putExtra("phoneno", pn);
startActivity(i);
}
}
else
pno.setError("The entered number is invalid!!");
}
});
}
}
通行证2:-
public class Pass2 extends Activity {
EditText codetxt=(EditText)findViewById(R.id.editText1);
String ph=codetxt.getText().toString();
Button codebtn=(Button)findViewById(R.id.button1);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent i = getIntent();
final String phn = i.getStringExtra("phoneno");
setContentView(R.layout.activity_pass2);
codebtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(ph.charAt(0)==phn.charAt(0) && ph.charAt(1)==phn.charAt(5) && ph.charAt(2)==phn.charAt(4) && ph.charAt(3)==phn.charAt(9))
{
if( codetxt.getText().toString().length()==4)
{
//code.setError("right number");
Intent i=new Intent(Pass2.this,Pass3.class);
startActivity(i);
}
}
else
codetxt.setError("Entered Code is wrong!");
}
});
}
}