{"id":368579,"date":"2024-05-21T03:45:29","date_gmt":"2024-05-21T03:45:29","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=368579"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=368579","title":{"rendered":"<span>AndroidFoodRecipesGuideTutorial<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><strong>\u0414\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0430\u0448\u0443 \u043a\u0443\u043b\u0438\u043d\u0430\u0440\u043d\u0443\u044e \u043b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u0438\u044e: \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0431\u043b\u044e\u0434!<\/strong><\/p>\n<blockquote>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0435\u0431\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e: \u0432\u044b \u0433\u043e\u043b\u043e\u0434\u043d\u044b, \u043d\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c. \u041a\u0430\u043a \u0436\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0432\u0430\u043c \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0435 \u0431\u043b\u044e\u0434\u0430, \u043d\u043e \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u0442 \u043e \u043d\u0438\u0445 \u0431\u043e\u043b\u044c\u0448\u0435! \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u0430\u043f\u043b\u044e \u044e\u043c\u043e\u0440\u0430 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u0434\u043e\u0432\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 Android.  <\/p>\n<\/blockquote>\n<h3>\u0428\u0430\u0433 1: \u041c\u043e\u0434\u0435\u043b\u044c \u0431\u043b\u044e\u0434\u0430<\/h3>\n<blockquote>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c\u0441\u044f, \u043a\u0430\u043a\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0431\u043b\u044e\u0434\u0435. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c <code>Dish<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435, \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u043f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430:  <\/p>\n<\/blockquote>\n<pre><code class=\"kotlin\">data class Dish(     val imageResId: Int,     val title: String,     val description: String,     val fullDescription: String )<\/code><\/pre>\n<h4>\u0428\u0430\u0433 2: XML \u043c\u0430\u043a\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043f\u0438\u0441\u043a\u0430<\/h4>\n<blockquote>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0431\u043b\u044e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0430\u043a\u0435\u0442\u0430 <code>list_item_dish.xml<\/code>. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438 \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430:<\/p>\n<\/blockquote>\n<pre><code class=\"kotlin\">&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"     android:layout_width=\"match_parent\"     android:layout_height=\"wrap_content\"     android:orientation=\"vertical\">      &lt;ImageView         android:id=\"@+id\/imageViewDish\"         android:layout_width=\"match_parent\"         android:layout_height=\"200dp\"         android:scaleType=\"centerCrop\"         android:src=\"@drawable\/default_dish_image\" \/>      &lt;TextView         android:id=\"@+id\/textViewTitle\"         android:layout_width=\"match_parent\"         android:layout_height=\"wrap_content\"         android:textStyle=\"bold\"         android:textSize=\"18sp\"         android:padding=\"8dp\" \/>      &lt;TextView         android:id=\"@+id\/textViewDescription\"         android:layout_width=\"match_parent\"         android:layout_height=\"wrap_content\"         android:padding=\"8dp\" \/>  &lt;\/LinearLayout> <\/code><\/pre>\n<h4>\u0428\u0430\u0433 3: RecyclerView \u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440<\/h4>\n<blockquote>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0431\u043b\u044e\u0434, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c RecyclerView \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0430\u0434\u0430\u043f\u0442\u0435\u0440 <code>DishAdapter<\/code>. \u042d\u0442\u043e\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u0431\u043b\u044e\u0434\u0430\u0445:<\/p>\n<\/blockquote>\n<pre><code class=\"kotlin\">class DishAdapter(private val dishes: List&lt;Dish>, private val listener: OnDishClickListener) :     RecyclerView.Adapter&lt;DishAdapter.DishViewHolder>() {      interface OnDishClickListener {         fun onDishClick(position: Int)     }      override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DishViewHolder {         val view = LayoutInflater.from(parent.context).inflate(R.layout.list_item_dish, parent, false)         return DishViewHolder(view)     }      override fun onBindViewHolder(holder: DishViewHolder, position: Int) {         val dish = dishes[position]         holder.imageView.setImageResource(dish.imageResId)         holder.textViewTitle.text = dish.title         holder.textViewDescription.text = dish.description          holder.itemView.setOnClickListener {             listener.onDishClick(position)         }     }      override fun getItemCount(): Int {         return dishes.size     }      class DishViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {         val imageView: ImageView = itemView.findViewById(R.id.imageViewDish)         val textViewTitle: TextView = itemView.findViewById(R.id.textViewTitle)         val textViewDescription: TextView = itemView.findViewById(R.id.textViewDescription)     } } <\/code><\/pre>\n<h4>\u0428\u0430\u0433 4: \u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430 \u0431\u043b\u044e\u0434<\/h4>\n<blockquote>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 <code>DishListFragment<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0431\u043b\u044e\u0434 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c RecyclerView \u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430:<\/p>\n<\/blockquote>\n<pre><code class=\"kotlin\">class DishListFragment : Fragment(), DishAdapter.OnDishClickListener {      private lateinit var binding: FragmentDishListBinding      override fun onCreateView(         inflater: LayoutInflater, container: ViewGroup?,         savedInstanceState: Bundle?     ): View {         binding = FragmentDishListBinding.inflate(inflater, container, false)         return binding.root     }      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {         super.onViewCreated(view, savedInstanceState)          val dishes = generateDummyDishes()          val adapter = DishAdapter(dishes, this)         binding.recyclerView.adapter = adapter         binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())     }      override fun onDishClick(position: Int) {         val dish = generateDummyDishes()[position]         val action = DishListFragmentDirections.actionDishListFragmentToDishDetailFragment(dish)         findNavController().navigate(action)     }      private fun generateDummyDishes(): List&lt;Dish> {         return listOf(             Dish(R.drawable.dish1, \"\u0411\u043b\u044e\u0434\u043e 1\", \"\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430 1\", \"\u041f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430 1\"),             Dish(R.drawable.dish2, \"\u0411\u043b\u044e\u0434\u043e 2\", \"\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430 2\", \"\u041f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430 2\"),             Dish(R.drawable.dish3, \"\u0411\u043b\u044e\u0434\u043e 3\", \"\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430 3\", \"\u041f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430 3\")         )     } } <\/code><\/pre>\n<h2>\u0428\u0430\u0433 4: \u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c \u0431\u043b\u044e\u0434\u0435:  <\/h2>\n<pre><code class=\"kotlin\">class DishDetailFragment : Fragment() {      private lateinit var binding: FragmentDishDetailBinding     private lateinit var dish: Dish      override fun onCreateView(         inflater: LayoutInflater, container: ViewGroup?,         savedInstanceState: Bundle?     ): View {         binding = FragmentDishDetailBinding.inflate(inflater, container, false)         return binding.root     }      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {         super.onViewCreated(view, savedInstanceState)          arguments?.let {             dish = DishDetailFragmentArgs.fromBundle(it).dish         }          binding.imageViewDish.setImageResource(dish.imageResId)         binding.textViewTitle.text = dish.title         binding.textViewDescription.text = dish.fullDescription     } }<\/code><\/pre>\n<blockquote>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e, \u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0431\u043b\u044e\u0434 \u043d\u0430 Android. \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Kotlin, RecyclerView \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430, \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u043a\u0440\u0430\u043d\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 (View Binding) \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u0430\u043a\u0435\u0442\u0430\u043c\u0438.<\/p>\n<p>\u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0431\u043b\u044e\u0434, \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0435\u0435 \u0435\u0433\u043e \u0431\u043b\u044e\u0434\u043e \u0438 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0431\u043b\u044e\u0434\u0430. \u042d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0435\u0440\u0435\u0434\u043e\u0432\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 Android.<\/p>\n<p>\u041c\u044b \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u0442 \u0432\u0430\u0441 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0438\u0445 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u0434 Android.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0447\u0442\u0435\u043d\u0438\u0435, \u0438 \u0443\u0434\u0430\u0447\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0438 \u0432 \u043c\u0438\u0440 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438!<\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/794654\/\"> https:\/\/habr.com\/ru\/articles\/794654\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><strong>\u0414\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0430\u0448\u0443 \u043a\u0443\u043b\u0438\u043d\u0430\u0440\u043d\u0443\u044e \u043b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u0438\u044e: \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0431\u043b\u044e\u0434!<\/strong><\/p>\n<blockquote>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0435\u0431\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e: \u0432\u044b \u0433\u043e\u043b\u043e\u0434\u043d\u044b, \u043d\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c. \u041a\u0430\u043a \u0436\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0432\u0430\u043c \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0435 \u0431\u043b\u044e\u0434\u0430, \u043d\u043e \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u0442 \u043e \u043d\u0438\u0445 \u0431\u043e\u043b\u044c\u0448\u0435! \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u0430\u043f\u043b\u044e \u044e\u043c\u043e\u0440\u0430 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u0434\u043e\u0432\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 Android.  <\/p>\n<\/blockquote>\n<h3>\u0428\u0430\u0433 1: \u041c\u043e\u0434\u0435\u043b\u044c \u0431\u043b\u044e\u0434\u0430<\/h3>\n<blockquote>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c\u0441\u044f, \u043a\u0430\u043a\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0431\u043b\u044e\u0434\u0435. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c <code>Dish<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435, \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u043f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430:  <\/p>\n<\/blockquote>\n<pre><code class=\"kotlin\">data class Dish(     val imageResId: Int,     val title: String,     val description: String,     val fullDescription: String )<\/code><\/pre>\n<h4>\u0428\u0430\u0433 2: XML \u043c\u0430\u043a\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043f\u0438\u0441\u043a\u0430<\/h4>\n<blockquote>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0431\u043b\u044e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0430\u043a\u0435\u0442\u0430 <code>list_item_dish.xml<\/code>. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438 \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430:<\/p>\n<\/blockquote>\n<pre><code class=\"kotlin\">&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"     android:layout_width=\"match_parent\"     android:layout_height=\"wrap_content\"     android:orientation=\"vertical\">      &lt;ImageView         android:id=\"@+id\/imageViewDish\"         android:layout_width=\"match_parent\"         android:layout_height=\"200dp\"         android:scaleType=\"centerCrop\"         android:src=\"@drawable\/default_dish_image\" \/>      &lt;TextView         android:id=\"@+id\/textViewTitle\"         android:layout_width=\"match_parent\"         android:layout_height=\"wrap_content\"         android:textStyle=\"bold\"         android:textSize=\"18sp\"         android:padding=\"8dp\" \/>      &lt;TextView         android:id=\"@+id\/textViewDescription\"         android:layout_width=\"match_parent\"         android:layout_height=\"wrap_content\"         android:padding=\"8dp\" \/>  &lt;\/LinearLayout> <\/code><\/pre>\n<h4>\u0428\u0430\u0433 3: RecyclerView \u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440<\/h4>\n<blockquote>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0431\u043b\u044e\u0434, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c RecyclerView \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0430\u0434\u0430\u043f\u0442\u0435\u0440 <code>DishAdapter<\/code>. \u042d\u0442\u043e\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u0431\u043b\u044e\u0434\u0430\u0445:<\/p>\n<\/blockquote>\n<pre><code class=\"kotlin\">class DishAdapter(private val dishes: List&lt;Dish>, private val listener: OnDishClickListener) :     RecyclerView.Adapter&lt;DishAdapter.DishViewHolder>() {      interface OnDishClickListener {         fun onDishClick(position: Int)     }      override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DishViewHolder {         val view = LayoutInflater.from(parent.context).inflate(R.layout.list_item_dish, parent, false)         return DishViewHolder(view)     }      override fun onBindViewHolder(holder: DishViewHolder, position: Int) {         val dish = dishes[position]         holder.imageView.setImageResource(dish.imageResId)         holder.textViewTitle.text = dish.title         holder.textViewDescription.text = dish.description          holder.itemView.setOnClickListener {             listener.onDishClick(position)         }     }      override fun getItemCount(): Int {         return dishes.size     }      class DishViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {         val imageView: ImageView = itemView.findViewById(R.id.imageViewDish)         val textViewTitle: TextView = itemView.findViewById(R.id.textViewTitle)         val textViewDescription: TextView = itemView.findViewById(R.id.textViewDescription)     } } <\/code><\/pre>\n<h4>\u0428\u0430\u0433 4: \u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430 \u0431\u043b\u044e\u0434<\/h4>\n<blockquote>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 <code>DishListFragment<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0431\u043b\u044e\u0434 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c RecyclerView \u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430:<\/p>\n<\/blockquote>\n<pre><code class=\"kotlin\">class DishListFragment : Fragment(), DishAdapter.OnDishClickListener {      private lateinit var binding: FragmentDishListBinding      override fun onCreateView(         inflater: LayoutInflater, container: ViewGroup?,         savedInstanceState: Bundle?     ): View {         binding = FragmentDishListBinding.inflate(inflater, container, false)         return binding.root     }      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {         super.onViewCreated(view, savedInstanceState)          val dishes = generateDummyDishes()          val adapter = DishAdapter(dishes, this)         binding.recyclerView.adapter = adapter         binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())     }      override fun onDishClick(position: Int) {         val dish = generateDummyDishes()[position]         val action = DishListFragmentDirections.actionDishListFragmentToDishDetailFragment(dish)         findNavController().navigate(action)     }      private fun generateDummyDishes(): List&lt;Dish> {         return listOf(             Dish(R.drawable.dish1, \"\u0411\u043b\u044e\u0434\u043e 1\", \"\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430 1\", \"\u041f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430 1\"),             Dish(R.drawable.dish2, \"\u0411\u043b\u044e\u0434\u043e 2\", \"\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430 2\", \"\u041f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430 2\"),             Dish(R.drawable.dish3, \"\u0411\u043b\u044e\u0434\u043e 3\", \"\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430 3\", \"\u041f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u043b\u044e\u0434\u0430 3\")         )     } } <\/code><\/pre>\n<h2>\u0428\u0430\u0433 4: \u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c \u0431\u043b\u044e\u0434\u0435:  <\/h2>\n<pre><code class=\"kotlin\">class DishDetailFragment : Fragment() {      private lateinit var binding: FragmentDishDetailBinding     private lateinit var dish: Dish      override fun onCreateView(         inflater: LayoutInflater, container: ViewGroup?,         savedInstanceState: Bundle?     ): View {         binding = FragmentDishDetailBinding.inflate(inflater, container, false)         return binding.root     }      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {         super.onViewCreated(view, savedInstanceState)          arguments?.let {             dish = DishDetailFragmentArgs.fromBundle(it).dish         }          binding.imageViewDish.setImageResource(dish.imageResId)         binding.textViewTitle.text = dish.title         binding.textViewDescription.text = dish.fullDescription     } }<\/code><\/pre>\n<blockquote>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e, \u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0431\u043b\u044e\u0434 \u043d\u0430 Android. \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Kotlin, RecyclerView \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430, \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u043a\u0440\u0430\u043d\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 (View Binding) \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u0430\u043a\u0435\u0442\u0430\u043c\u0438.<\/p>\n<p>\u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0431\u043b\u044e\u0434, \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0435\u0435 \u0435\u0433\u043e \u0431\u043b\u044e\u0434\u043e \u0438 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0431\u043b\u044e\u0434\u0430. \u042d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0435\u0440\u0435\u0434\u043e\u0432\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 Android.<\/p>\n<p>\u041c\u044b \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u0442 \u0432\u0430\u0441 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0438\u0445 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u0434 Android.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0447\u0442\u0435\u043d\u0438\u0435, \u0438 \u0443\u0434\u0430\u0447\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0438 \u0432 \u043c\u0438\u0440 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438!<\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/794654\/\"> https:\/\/habr.com\/ru\/articles\/794654\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-368579","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/368579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=368579"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/368579\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=368579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=368579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=368579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}