0
Hello I’m running a debug on this code and at the end it gives this message in debug.
Cannot find local variable 'Namespace'
However I already searched all my code and I do not find this variable do not know what to do thinking of redoing the code I do not know if it can be a garbage that is in some file.
But before that I was wondering if you’ve ever had anything like this.
public class CriarPrato extends AppCompatActivity {
private Spinner LocalRestaurante;
private Spinner NomeRestaurante;
private EditText NomePrato;
private EditText PrecoPrato;
private Button GerarPrato;
private String IDrestaurante;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_criar_prato);
LocalRestaurante = (Spinner) findViewById(R.id.SpinerLocalPrato);
NomeRestaurante = (Spinner) findViewById(R.id.spinnerNomeRestaurantePrato);
NomePrato = (EditText) findViewById(R.id.editTextNomePrato);
PrecoPrato = (EditText) findViewById(R.id.editTextPrecoPrato);
GerarPrato = (Button) findViewById(R.id.buttonPrato);
Query queryPrato = ConfiguracaoFirebase.getReferencia().child("Restaurante").orderByChild("localRestaurante");
queryPrato.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
final List<String> localRest = new ArrayList<String>();
final List<String> NomeRestauranteList = new ArrayList<String>();
for (DataSnapshot data : dataSnapshot.getChildren()) {
Restaurante restaurante = data.getValue(Restaurante.class);
localRest.add(restaurante.getLocalRestaurante().toString());
NomeRestauranteList.add(restaurante.getNome().toString());
}
LocalRestaurante = (Spinner) findViewById(R.id.SpinerLocalPrato);
ArrayAdapter<String> areas = new ArrayAdapter<String>(getApplicationContext(), R.layout.spinner_item, localRest);
areas.setDropDownViewResource(R.layout.spinner_item);
LocalRestaurante.setAdapter(areas);
NomeRestaurante = (Spinner) findViewById(R.id.spinnerNomeRestaurantePrato);
ArrayAdapter<String> NomeRestAdapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.spinner_item, NomeRestauranteList);
NomeRestAdapter.setDropDownViewResource(R.layout.spinner_item);
NomeRestaurante.setAdapter(NomeRestAdapter);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
GerarPrato.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Prato prato = new Prato();
String NomeSelcRestaurante= NomeRestaurante.getSelectedItem().toString();
Query queryPrato2 = ConfiguracaoFirebase.getReferencia().child("Restaurante").orderByChild("nome").equalTo(NomeSelcRestaurante);
queryPrato2.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
IDrestaurante = dataSnapshot.getValue().toString();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
prato.setNomePrato(NomePrato.getText().toString());
prato.setPrecoPrato("R$"+ PrecoPrato.getText().toString());
prato.setID(IDrestaurante);
prato.Salvar(IDrestaurante);
}
});
}
}
xml file.
TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Favor selecionar o local do restaurante."
android:textAlignment="center"
android:textColor="@color/common_google_signin_btn_text_dark_focused"
android:textSize="24sp"
tools:ignore="HardcodedText,MissingConstraints,RtlHardcoded"
tools:layout_constraintTop_creator="1"
android:layout_marginTop="47dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<Spinner
android:id="@+id/SpinerLocalPrato"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView3"
tools:ignore="MissingConstraints"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toTopOf="@+id/spinnerNomeRestaurantePrato"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="121dp"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="124dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/editTextNomePrato"
android:layout_centerHorizontal="true"
android:text="Favor selecionar o restaurante."
android:textAlignment="center"
android:textColor="@color/common_google_signin_btn_text_dark_focused"
android:textSize="24sp"
tools:ignore="HardcodedText,MissingConstraints"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0.502"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toTopOf="@+id/spinnerNomeRestaurantePrato"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="46dp" />
<EditText
android:id="@+id/editTextNomePrato"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/editTextPrecoPrato"
android:layout_alignParentStart="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:ems="10"
android:inputType="textPersonName"
android:text="Nome do Prato"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
tools:ignore="HardcodedText,LabelFor,MissingConstraints"
app:layout_constraintHorizontal_bias="1.0"
android:layout_marginEnd="16dp"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
android:layout_marginTop="49dp"
app:layout_constraintTop_toBottomOf="@+id/spinnerNomeRestaurantePrato"
tools:layout_constraintLeft_creator="1" />
<EditText
android:id="@+id/editTextPrecoPrato"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_above="@+id/ButtonCriarPrato"
android:layout_alignParentStart="true"
android:ems="10"
android:inputType="numberDecimal"
android:text="Preço"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="@+id/editTextNomePrato"
app:layout_constraintRight_toRightOf="@+id/editTextNomePrato"
tools:ignore="HardcodedText,LabelFor,MissingConstraints,UnknownId"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintTop_creator="1"
app:layout_constraintBottom_toTopOf="@+id/buttonPrato"
android:layout_marginTop="39dp"
android:layout_marginBottom="44dp"
app:layout_constraintTop_toTopOf="@+id/editTextNomePrato" />
<Spinner
android:id="@+id/spinnerNomeRestaurantePrato"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_above="@+id/editTextNomePrato"
android:layout_alignParentStart="true"
tools:ignore="MissingConstraints"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="269dp"
tools:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/buttonPrato"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
tools:ignore="HardcodedText,MissingConstraints"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toBottomOf="parent"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="51dp" />
valeu worked !!! :)
– IMoonBlackI
Gave a Rebuild Project
– IMoonBlackI
Boa =) Victort...
– Dev