fragments
This commit is contained in:
1
.idea/deploymentTargetSelector.xml
generated
1
.idea/deploymentTargetSelector.xml
generated
@@ -4,6 +4,7 @@
|
||||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DialogSelection />
|
||||
</SelectionState>
|
||||
</selectionStates>
|
||||
</component>
|
||||
|
||||
@@ -13,6 +13,24 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.LifeGrid">
|
||||
<activity
|
||||
android:name=".NovaTransacao"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.NovaTranscao"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
|
||||
71
app/src/main/java/com/example/lifegrid/NovaTransacao.java
Normal file
71
app/src/main/java/com/example/lifegrid/NovaTransacao.java
Normal file
@@ -0,0 +1,71 @@
|
||||
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");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
app/src/main/res/layout/activity_nova_transacao.xml
Normal file
36
app/src/main/res/layout/activity_nova_transacao.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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>
|
||||
@@ -5,10 +5,5 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".menu.DefinicoesFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
|
||||
</FrameLayout>
|
||||
Reference in New Issue
Block a user