4
I’m trying to start programming on Android. I created the project and came this code:
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.tela_1);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.main1, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
int id = item.getItemId();
if (id == R.id.action_settings)
{
return true;
}
return super.onOptionsItemSelected(item);
}
but with those mistakes:
How to solve ??
It means that the tela_1 is not present in the presentation of the APK.
– Mega
But the project was created like this, I didn’t change anything.
– Lucas Caresia
https://missaodeveloper.wordpress.com/2013/09/11/activity-do-android-e-o-metodo-oncreate/ [EN]
– Mega
The problem should be the import of the R class. See the Imports in the class and first remove the import from the R class, then position the cursor on the variable with the error, press the ALT+ENTER shortcut and import it again
– Skywalker
See the folder res > layout if there is a file called tela_1.xml. If you don’t have this problem.
– George
First of all I suggest you migrate to Android Studio, since Eclipse support has been discontinued and also the code generated by it is from a discontinued version of SDK.
– Rodrigo Henriques