I would like to store an ImageButton with an image, an audio, and the position where it sits within the Realm database. It's possible? I'm starting with Realm now and I've only been able to store, delete, and show a string from some EditText.
I put my ImageButton the normal way and I want to move to Realm so I can put it in more than one Tab.
Button:
vitasbut.setOnClickListener(new ImageButton.OnClickListener() {
@Override
public void onClick(View v) {
vitasbut.setImageResource(R.drawable.vitas1);
play(vitasblblblahahah);
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
vitasbut.setImageResource(R.drawable.vitas1e2);
}
});
}
});
tab1.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fundotela"
android:layout_width="match_parent"
android:layout_height="match_parent"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toTopOf="parent"
tools:context="com.example.mateuspc1.memepocket.MainActivity">
<ScrollView
android:id="@+id/ScrollView01"
android:layout_width="0dp"
android:layout_height="0dp"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintHorizontal_bias="1.0"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toTopOf="parent"
ads:layout_constraintVertical_bias="1.0">
<android.support.constraint.ConstraintLayout
android:id="@+id/scrollcontainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/mulheratebut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:layout_constraintStart_toEndOf="@+id/porratudoissobut"
ads:layout_constraintTop_toBottomOf="@+id/vcfalademaisamigobut"
ads:srcCompat="@drawable/mememulheratedebaixodaguae2" />
<ImageButton
android:id="@+id/porratudoissobut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toBottomOf="@+id/apostoquenaofoibut"
ads:srcCompat="@drawable/memeporratudoissoe2" />
<ImageButton
android:id="@+id/tirosbut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintStart_toEndOf="@+id/vcfalademaisamigobut"
ads:layout_constraintTop_toBottomOf="@+id/equemfoiocagaobut"
ads:srcCompat="@drawable/memetirose2" />
<ImageButton
android:id="@+id/vcfalademaisamigobut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:layout_constraintEnd_toStartOf="@+id/tirosbut"
ads:layout_constraintStart_toEndOf="@+id/apostoquenaofoibut"
ads:layout_constraintTop_toBottomOf="@+id/ummontedebostabut"
ads:srcCompat="@drawable/memevocefalademaisamigoe2" />
<ImageButton
android:id="@+id/apostoquenaofoibut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
ads:layout_constraintEnd_toStartOf="@+id/vcfalademaisamigobut"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toBottomOf="@+id/quelevasnessecaixaobut"
ads:srcCompat="@drawable/memeapostoquenaofoie2" />
<ImageButton
android:id="@+id/equemfoiocagaobut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintStart_toEndOf="@+id/ummontedebostabut"
ads:layout_constraintTop_toBottomOf="@+id/falaoquevcquerbut"
ads:srcCompat="@drawable/memeequemfoiocagaoe2" />
<ImageButton
android:id="@+id/ummontedebostabut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:layout_constraintEnd_toStartOf="@+id/equemfoiocagaobut"
ads:layout_constraintStart_toEndOf="@+id/quelevasnessecaixaobut"
ads:layout_constraintTop_toBottomOf="@+id/ummomentoamigobut"
ads:srcCompat="@drawable/memeummontedebostae2" />
<ImageButton
android:id="@+id/quelevasnessecaixaobut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
ads:layout_constraintEnd_toStartOf="@+id/ummontedebostabut"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toBottomOf="@+id/aindabembut"
ads:srcCompat="@drawable/memequelevasnessecaixaoe2" />
<ImageButton
android:id="@+id/falaoquevcquerbut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintStart_toEndOf="@+id/ummomentoamigobut"
ads:layout_constraintTop_toBottomOf="@+id/naogracinhabut"
ads:srcCompat="@drawable/memefalaoquevcquere2" />
<ImageButton
android:id="@+id/ummomentoamigobut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:layout_constraintEnd_toStartOf="@+id/falaoquevcquerbut"
ads:layout_constraintStart_toEndOf="@+id/aindabembut"
ads:layout_constraintTop_toBottomOf="@+id/faloucomigobut"
ads:srcCompat="@drawable/memeummomentoamigoe2" />
<ImageButton
android:id="@+id/aindabembut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
ads:layout_constraintEnd_toStartOf="@+id/ummomentoamigobut"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toBottomOf="@+id/eiseubundamolebut"
ads:srcCompat="@drawable/memeaindabeme2" />
<ImageButton
android:id="@+id/naogracinhabut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintStart_toEndOf="@+id/faloucomigobut"
ads:layout_constraintTop_toBottomOf="@+id/fausttapegfogbut"
ads:srcCompat="@drawable/memenaogracinhae2" />
<ImageButton
android:id="@+id/faloucomigobut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:layout_constraintEnd_toStartOf="@+id/naogracinhabut"
ads:layout_constraintStart_toEndOf="@+id/eiseubundamolebut"
ads:layout_constraintTop_toBottomOf="@+id/fausteroubut"
ads:srcCompat="@drawable/memefaloucomigoe2" />
<ImageButton
android:id="@+id/eiseubundamolebut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
ads:layout_constraintEnd_toStartOf="@+id/faloucomigobut"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toBottomOf="@+id/bnsetimaartebut"
ads:srcCompat="@drawable/memeeiseubundamolee2" />
<ImageButton
android:id="@+id/vitasbut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="5dp"
android:contentDescription="@string/todo"
android:src="@drawable/vitas1e2"
ads:layout_constraintBottom_toTopOf="@+id/gtabut"
ads:layout_constraintEnd_toStartOf="@+id/vitasbut2"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/vitasbut2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:contentDescription="@string/todo"
android:src="@drawable/vitas2e2"
ads:layout_constraintBottom_toTopOf="@+id/gtabut2"
ads:layout_constraintEnd_toStartOf="@+id/aiaichoquebut"
ads:layout_constraintStart_toEndOf="@+id/vitasbut"
ads:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/gtabut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:contentDescription="@string/todo"
android:src="@drawable/gta1e2"
ads:layout_constraintBottom_toTopOf="@+id/bolsbut"
ads:layout_constraintEnd_toStartOf="@+id/gtabut2"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toBottomOf="@+id/vitasbut" />
<ImageButton
android:id="@+id/gtabut2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/todo"
android:src="@drawable/gta2e2"
ads:layout_constraintBottom_toTopOf="@+id/bolsbut2"
ads:layout_constraintEnd_toStartOf="@+id/gabebut"
ads:layout_constraintStart_toEndOf="@+id/gtabut"
ads:layout_constraintTop_toBottomOf="@+id/vitasbut2" />
<ImageButton
android:id="@+id/gabebut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:contentDescription="@string/todo"
android:src="@drawable/gabe1e2"
ads:layout_constraintBottom_toTopOf="@+id/acertomizbut"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintStart_toEndOf="@+id/gtabut2"
ads:layout_constraintTop_toBottomOf="@+id/aiaichoquebut" />
<ImageButton
android:id="@+id/bolsbut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:contentDescription="@string/todo"
android:src="@drawable/bols1e2"
ads:layout_constraintBottom_toTopOf="@+id/bnsetimaartebut"
ads:layout_constraintEnd_toStartOf="@+id/bolsbut2"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toBottomOf="@+id/gtabut" />
<ImageButton
android:id="@+id/bolsbut2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/todo"
android:src="@drawable/bols2e2"
ads:layout_constraintBottom_toTopOf="@+id/fausteroubut"
ads:layout_constraintEnd_toStartOf="@+id/acertomizbut"
ads:layout_constraintStart_toEndOf="@+id/bolsbut"
ads:layout_constraintTop_toBottomOf="@+id/gtabut2" />
<ImageButton
android:id="@+id/acertomizbut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="@drawable/acertmiz1e2"
ads:layout_constraintBottom_toTopOf="@+id/fausttapegfogbut"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintStart_toEndOf="@+id/bolsbut2"
ads:layout_constraintTop_toBottomOf="@+id/gabebut" />
<ImageButton
android:id="@+id/aiaichoquebut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginTop="5dp"
android:src="@drawable/aiaichoque1e2"
ads:layout_constraintBottom_toTopOf="@+id/gabebut"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintStart_toEndOf="@+id/vitasbut2"
ads:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/bnsetimaartebut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:src="@drawable/bnsetimaarte1e2"
ads:layout_constraintEnd_toStartOf="@+id/fausteroubut"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toBottomOf="@+id/bolsbut" />
<ImageButton
android:id="@+id/fausteroubut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/fausterou1e2"
ads:layout_constraintEnd_toStartOf="@+id/fausttapegfogbut"
ads:layout_constraintStart_toEndOf="@+id/bnsetimaartebut"
ads:layout_constraintTop_toBottomOf="@+id/bolsbut2" />
<ImageButton
android:id="@+id/fausttapegfogbut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="@drawable/faustfogo1e2"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintStart_toEndOf="@+id/fausteroubut"
ads:layout_constraintTop_toBottomOf="@+id/acertomizbut" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="320dp"
android:layout_height="50dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="21dp"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toBottomOf="@+id/mulheratebut"
ads:srcCompat="@android:color/transparent" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>