最后一行和第四行“EditText numTxt;”包含错误,但我似乎无法解决它,它说错过了}但是当我输入这些或类似的东西时它没有解决。 不确定这里的问题是什么,但我正在按照教程进行操作,这正是代码的样子
public class SecondScreen extends Activity {
Button sendSMS;
EditText msgTxt;
EditText numTxt;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.secondscreen);
TextView SecondScreenText = (TextView) findViewById(R.id.SecondScreenText);
Intent i = getIntent();
// Receiving the Data
String value = i.getStringExtra("value");
// Displaying Received data
SecondScreenText.setText(value);
sendSMS = (Button) findViewById(R.id.sendsms);
msgTxt = (EditText) findViewById(R.id.message);
numTxt = (EditText) findViewById(R.id.number);
sendSMS.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String myMsg = msgTxt.getText().toString();
String theNumber = numTxt.getText().toString();
sendMsg(theNumber, myMsg);
Button next = (Button) findViewById(R.id.Button02);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent();
setResult(RESULT_OK, intent);
finish();
}
});
}
protected void sendMsg(String theNumber, String myMsg) {
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(theNumber, null, myMsg, null, null);
}
}
答案 0 :(得分:0)
只需在此语句完成时结束您的代码,即:
protected void sendMsg(String theNumber, String myMsg) {
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(theNumber, null, myMsg, null, null);}
});}}
希望能帮到你。