erro
This commit is contained in:
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
@@ -0,0 +1 @@
|
|||||||
|
LifeGrid
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
package com.example.lifegrid;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.core.graphics.Insets;
|
|
||||||
import androidx.core.view.ViewCompat;
|
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
|
||||||
|
|
||||||
public class NovaTransacao extends AppCompatActivity {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
EdgeToEdge.enable(this);
|
|
||||||
setContentView(R.layout.activity_nova_transacao);
|
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
|
||||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
|
||||||
return insets;
|
|
||||||
});
|
|
||||||
// 1. Encontrar os elementos no ecrã
|
|
||||||
Button botaoPrincipal = findViewById(R.id.botaoPrincipal);
|
|
||||||
LinearLayout grupoOpcoes = findViewById(R.id.grupoOpcoes);
|
|
||||||
Button botaoOpcao1 = findViewById(R.id.botaoOpcao1);
|
|
||||||
Button botaoOpcao2 = findViewById(R.id.botaoOpcao2);
|
|
||||||
|
|
||||||
// 2. Lógica para mostrar/esconder as opções
|
|
||||||
botaoPrincipal.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
// Se as opções estiverem escondidas, mostra-as. Se estiverem à vista, esconde-as.
|
|
||||||
if (grupoOpcoes.getVisibility() == View.GONE) {
|
|
||||||
grupoOpcoes.setVisibility(View.VISIBLE);
|
|
||||||
botaoPrincipal.setText("Esconder Opções"); // Muda o texto do botão
|
|
||||||
} else {
|
|
||||||
grupoOpcoes.setVisibility(View.GONE);
|
|
||||||
botaoPrincipal.setText("Mostrar Opções");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 3. Lógica para quando o utilizador escolhe uma opção
|
|
||||||
botaoOpcao1.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
Toast.makeText(NovaTransacao.this, "Escolheste a Opção 1", Toast.LENGTH_SHORT).show();
|
|
||||||
// Opcional: esconder a lista depois de escolher
|
|
||||||
grupoOpcoes.setVisibility(View.GONE);
|
|
||||||
botaoPrincipal.setText("Mostrar Opções");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
botaoOpcao2.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
Toast.makeText(NovaTransacao.this, "Escolheste a Opção 2", Toast.LENGTH_SHORT).show();
|
|
||||||
// Opcional: esconder a lista depois de escolher
|
|
||||||
grupoOpcoes.setVisibility(View.GONE);
|
|
||||||
botaoPrincipal.setText("Mostrar Opções");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="16dp">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/botaoPrincipal"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Mostrar Opções" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/grupoOpcoes"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_marginTop="8dp">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/botaoOpcao1"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Opção 1"
|
|
||||||
style="?android:attr/buttonBarButtonStyle" /> <Button
|
|
||||||
android:id="@+id/botaoOpcao2"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Opção 2"
|
|
||||||
style="?android:attr/buttonBarButtonStyle" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
Reference in New Issue
Block a user