Answer the question
In order to leave comments, you need to log in
Method not created, why?
For some reason, it is not possible to run the code, sometimes a similar error occurs, but in different projects. Please explain what is wrong with textViewOrder = findViewById(R.id.textViewOrder); ? The code is not mine, everything is from the video tutorial on Android with Udemy (the code is copied exactly).
package com.demo.cafeorder;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
public class OrderDetailActivity extends AppCompatActivity {
private TextView textViewOrder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_order_detail);
textViewOrder = findViewById(R.id.textViewOrder);
Intent intent = getIntent();
if (intent.hasExtra("order")) {
String order = intent.getStringExtra("order");
textViewOrder.setText(order);
} else {
Intent backToLogin = new Intent(this, LoginActivity.class);
startActivity(backToLogin);
}
}
}
Answer the question
In order to leave comments, you need to log in
It is written in red on gray that the Studio does not see a resource with the identifier textViewOrder. The first step is to check that there is an element with this ID in the layouts. If indeed there is, but the error persists, then try Build->Clean Project, File->Sync Project with Gradle Files and File -> Invalidate Caches / Restart.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question