Skip to content

Commit

Permalink
NewsDetailsFragment: Pop fragment from backstack when back button is …
Browse files Browse the repository at this point in the history
…clicked
  • Loading branch information
jashasweejena committed Nov 2, 2021
1 parent 210e7fc commit 2ac31b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.navigation.NavController
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import com.example.newsreader.data.models.Article
import com.example.newsreader.databinding.FragmentNewsDetailsBinding
Expand Down Expand Up @@ -39,6 +41,9 @@ class NewsDetailsFragment @Inject constructor() : Fragment(), HasAndroidInjector
): View {
binding = FragmentNewsDetailsBinding.inflate(inflater, container, false)
binding.news = news
binding.home.setOnClickListener {
findNavController().popBackStack()
}
return binding.root
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_news_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
android:scaleType="center" />

<ImageView
android:id="@android:id/home"
android:id="@+id/home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dp"
Expand Down

0 comments on commit 2ac31b9

Please sign in to comment.