adding a like and unlike buttons to each picture from GridView when gets open in the second Activity?

29 Views Asked by At

I have a gridView filled with pictures when i click on any picture, the picture gets displayed in the SecondActivit, i want to add a like and unlike button to each picture that dispaly in the SecondActivity and save the number of likes that each picture gets. if anyone have anyidea please help.

1

There are 1 best solutions below

0
mihir raj On

Firstly, you can make one activity like following,

    <activity
        android:name="potenza.photo.vault.ui.activities.FullScreenPhotoActivity"
        android:theme="@style/OverlayTheme" />
    <activity>

Create option menu like below,

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="your_activity">
 <item android:id="@+id/action_like_photo"
    android:icon="@drawable/like" android:title="Like"
    android:orderInCategory="100" app:showAsAction="always" />
 <item android:id="@+id/action_dislike_photo"
    android:icon="@drawable/like" android:title="Dislike"
    android:orderInCategory="100" app:showAsAction="always" />
</menu>

Start activity using startIntent and put an extra (photo id). You can save likes/unlikes using shared preferences.