我有这段代码:
if (!errors.isEmpty()) {
Context context = getApplicationContext();
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, errors, duration);
toast.show();
} else {
// Success! Cache the inputs and continue with registration.
SharedPreferences settings = getSharedPreferences("settings", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("name", name);
editor.putString("email", email);
editor.putString("password", password);
Intent i = new Intent(view.getContext(),
sendRegisterActivity.class);
startActivityForResult(i, 0);
}
现在,这是在public void sendRegistration(View view)
范围内,点按一下按钮就会触发。每当我拿走“else”语句的最后3行时,它就有效。但是当我添加它时,我得到“无法找到源”。 sendRegisterActivity.java存在,但我仍然遇到错误。这就是sendRegisterActivity的外观:
public class sendRegisterActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sendregister);
}
}
sendregister.xml位于“layout”文件夹中,并且完全有效。
答案 0 :(得分:3)
您是否已将sendRegisterActivity添加到清单中?