Implement Swipe Info
This commit is contained in:
parent
2f38b0eed7
commit
71bc0623a5
@ -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();
|
||||
}
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user