Я взял некоторый код, чтобы создать простую форму на Android. Кажется, что некоторые части кода ссылаются на что-то. Я не уверен, что положить туда, чтобы он работал? Я получаю ошибки.Создание формы на студии android
Error:(18, 32) error: cannot find symbol variable activity_form
Error:(33, 88) error: package com.chalkstreet.learnandroid.main does not exist
Error:(48, 50) error: cannot find symbol class MainSource
Error:(57, 41) error: cannot find symbol variable menu_main
Я не думаю, что мне нужно использовать пакет, который я не имеющий.
Пример проблемы:
Intent sender = new Intent(Form.this,
===> ???? com.chalkstreet.learnandroid.main.Display.class);
Вот моя форма:
public class Form extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_form);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//Initialize buttons and Edit Texts for form
Button btnSubmit = (Button) findViewById(R.id.button_submit);
Button btnSrc = (Button) findViewById(R.id.buttonSrc);
final EditText name = (EditText) findViewById(R.id.editText1);
final EditText email = (EditText) findViewById(R.id.editText2);
final EditText phone = (EditText) findViewById(R.id.editText4);
//Listener on Submit button
btnSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent sender = new Intent(Form.this, com.chalkstreet.learnandroid.main.Display.class);
Bundle b1 = new Bundle(); //Bundle to wrap all data
b1.putString("name", name.getText().toString()); //Adding data to bundle
b1.putString("email", email.getText().toString());
b1.putString("phone", phone.getText().toString());
sender.putExtras(b1); //putExtras method to send the bundle
startActivity(sender);
Form.this.finish(); //Finish form activity to remove it from stack
}
});
//Listener on source button
btnSrc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent j = new Intent(Form.this, MainSource.class);
startActivity(j);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
Form.this.finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}
Благодаря
Кажется, вы не создали файлы xml, activity_form.xml и menu_main.xml, также возможно, что вы не создали MainSource.java, или если это внутренний класс, вы не включили родительский файл. –