Implement Swipe Info

This commit is contained in:
Fawkes100 2025-01-18 19:02:48 +01:00
parent 2f38b0eed7
commit 71bc0623a5
2 changed files with 16 additions and 1 deletions

View File

@ -4,6 +4,8 @@ import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager2.widget.ViewPager2;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
import com.stormtales.notevault.R;
import java.util.Arrays;
@ -16,6 +18,9 @@ public class NoteSheetDisplayActivity extends AppCompatActivity {
setContentView(R.layout.activity_note_sheet_viewer); // Erstelle eine Layout-Datei
ViewPager2 imageView = findViewById(R.id.viewPager); // Angenommen, du hast ein ImageView
TabLayout tabLayout = findViewById(R.id.tabLayout);
// Die URI aus dem Intent erhalten
Intent intent = getIntent();
@ -24,6 +29,10 @@ public class NoteSheetDisplayActivity extends AppCompatActivity {
List<String> uriList = Arrays.asList(imageUris);
ImagePagerAdapter adapter = new ImagePagerAdapter(this, uriList);
imageView.setAdapter(adapter); // Setze die URI in das ImageView
new TabLayoutMediator(tabLayout, imageView,
(tab, position) -> tab.setText("Sheet " + (position + 1)) // Hier kannst du auch andere Labels verwenden
).attach();
} else {
throw new NullPointerException();
}

View File

@ -2,7 +2,13 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- TabLayout für die Swipe-Indikatoren -->
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="?android:attr/windowBackground"/>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager"