{"id":19317893,"url":"https://github.com/queeniecplusplus/android_review_24","last_synced_at":"2026-04-26T20:31:33.986Z","repository":{"id":104588082,"uuid":"340069058","full_name":"QueenieCplusplus/Android_Review_24","owner":"QueenieCplusplus","description":"GridView, Pass Param between two diff Destination within NavigationUI","archived":false,"fork":false,"pushed_at":"2021-02-18T14:42:11.000Z","size":932,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-04T20:10:55.504Z","etag":null,"topics":["android","e-commerce","fragment","gridview","kotlin","listadapter","simpleadapter"],"latest_commit_sha":null,"homepage":"https://github.com/QueenieCplusplus/QuickGoThru/blob/master/README.md#google-android-kotlin-溫故安卓---計畫復甦","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QueenieCplusplus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-18T14:06:28.000Z","updated_at":"2021-02-18T14:42:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"decbbdd5-ca87-4da6-a657-b2b41f96de3f","html_url":"https://github.com/QueenieCplusplus/Android_Review_24","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/QueenieCplusplus/Android_Review_24","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QueenieCplusplus%2FAndroid_Review_24","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QueenieCplusplus%2FAndroid_Review_24/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QueenieCplusplus%2FAndroid_Review_24/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QueenieCplusplus%2FAndroid_Review_24/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QueenieCplusplus","download_url":"https://codeload.github.com/QueenieCplusplus/Android_Review_24/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QueenieCplusplus%2FAndroid_Review_24/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32312204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T19:15:34.056Z","status":"ssl_error","status_checked_at":"2026-04-26T19:15:15.467Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","e-commerce","fragment","gridview","kotlin","listadapter","simpleadapter"],"created_at":"2024-11-10T01:16:34.260Z","updated_at":"2026-04-26T20:31:33.970Z","avatar_url":"https://github.com/QueenieCplusplus.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Android_Review_24\nGridView, Pass Param between two diff Destination within NavigationUI\n\n![](https://raw.githubusercontent.com/QueenieCplusplus/Android_Review_24/main/output1.png)\n\n![](https://raw.githubusercontent.com/QueenieCplusplus/Android_Review_24/main/output2.png)\n\n![](https://raw.githubusercontent.com/QueenieCplusplus/Android_Review_24/main/output3.png)\n\n# safe-args:\n\ntop level build gradle =\u003e\n\n\n    dependencies {\n\n        def nav_version = \"2.3.3\"\n        classpath \"androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version\"\n        \n        ...\n        \n      }\n      \napp level build gradle =\u003e\n\n\n    plugins {\n        id 'com.android.application'\n        id 'kotlin-android'\n        id 'kotlin-kapt'\n        id 'androidx.navigation.safeargs.kotlin'\n\n    }\n\n\n    dependencies {\n\n\n        // Navigation\n        implementation \"android.arch.navigation:navigation-fragment-ktx:$version_navigation\"\n        implementation \"android.arch.navigation:navigation-ui-ktx:$version_navigation\"\n\n     }\n     \n     \n # pass pararm betweem 2 diff destination using Bundle =\u003e\n \n \n sending frag:\n \n      \n       this.component!!.onItemClickListener = AdapterView.OnItemClickListener { _, _, position, _ -\u003e\n            Toast.makeText(this.activity, \"selected item：\" + label[position], Toast.LENGTH_SHORT).show()\n            \n            \n            // pass param between 2 destinations\n            val j = label[position].toString()\n            val bundle = bundleOf(\"j\" to j)\n            findNavController().navigate(R.id.action_mainFragment_to_detailFragment, bundle)\n            \n            \n            \n            //findNavController().navigate(action_mainFragment_to_detailFragment)\n      }\n \n \n receiving frag:\n \n       // pass param between 2 destinations\n        var st = arguments?.getString(\"j\")\n        this.tv2!!.text = st\n\n     \n     \n# Navigation\n\n\nset Navigaton Host on Activity_Main.xml =\u003e\n\n     \u003cfragment\n        android:id=\"@+id/nav_host_fragment\"\n        android:name=\"androidx.navigation.fragment.NavHostFragment\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"450dp\"\n        android:layout_gravity=\"center_vertical\"\n        android:layout_marginTop=\"90dp\"\n        android:layout_marginBottom=\"141dp\"\n        app:defaultNavHost=\"true\"\n        app:layout_constraintBottom_toBottomOf=\"parent\"\n        app:layout_constraintEnd_toEndOf=\"parent\"\n        app:layout_constraintStart_toStartOf=\"parent\"\n        app:layout_constraintTop_toTopOf=\"parent\"\n        app:navGraph=\"@navigation/nav_graph\" /\u003e\n        \n        \n add 2 diff fragments, then .... add them to nav_graph\n\n res/navigation/nav_graph.xml =\u003e\n \n     \u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n    \u003cnavigation xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n        xmlns:tools=\"http://schemas.android.com/tools\"\n        android:id=\"@+id/nav_graph\"\n        app:startDestination=\"@id/mainFragment\"\u003e\n\n        \u003cfragment\n            android:id=\"@+id/mainFragment\"\n            android:name=\"com.katepatty.katesshop.ui.main.MainFragment\"\n            android:label=\"main_fragment\"\n            tools:layout=\"@layout/main_fragment\" \u003e\n            \u003caction\n                android:id=\"@+id/action_mainFragment_to_detailFragment\"\n                app:destination=\"@id/detailFragment\" /\u003e\n            \u003cargument\n                android:name=\"myArg\"\n                app:argType=\"integer\"\n                android:defaultValue=\"0\" /\u003e\n        \u003c/fragment\u003e\n        \u003cfragment\n            android:id=\"@+id/detailFragment\"\n            android:name=\"com.katepatty.katesshop.ui.main.DetailFragment\"\n            android:label=\"fragment_detail\"\n            tools:layout=\"@layout/fragment_detail\" /\u003e\n    \u003c/navigation\u003e\n\n# GridView\n\n   add GridView component in one of the fragment to do overview UI.\n\n        \u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n        \u003cRelativeLayout\n            xmlns:android=\"http://schemas.android.com/apk/res/android\"\n            xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n            xmlns:tools=\"http://schemas.android.com/tools\"\n            android:id=\"@+id/main\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            tools:context=\".ui.main.MainFragment\"\u003e\n\n            \u003cGridView\n                android:id=\"@+id/gv\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\n                android:numColumns=\"auto_fit\"\n                android:gravity=\"center\"\n                android:columnWidth=\"135dp\"\n                android:stretchMode=\"columnWidth\"\u003e\n\n            \u003c/GridView\u003e\n\n        \u003c/RelativeLayout\u003e\n        \n   within its items show in Gridview. (as same as RecycleView)\n   \n       \u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\n        \u003cLinearLayout\n            xmlns:android=\"http://schemas.android.com/apk/res/android\"\n            xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            android:gravity=\"center\"\n            android:orientation=\"vertical\"\u003e\n\n\n            \u003cImageView\n                android:id=\"@+id/img\"\n                android:layout_width=\"130dp\"\n                android:layout_height=\"110dp\"\n                android:layout_marginTop=\"10dp\"\n                android:contentDescription=\"@string/todo\" /\u003e\n\n            \u003cTextView\n                android:id=\"@+id/txt\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\n                android:gravity=\"center\"\n                android:paddingTop=\"8dp\"\n                android:paddingBottom=\"8dp\"\n                android:textSize=\"15dp\" /\u003e\n        \u003c/LinearLayout\u003e\n   \n   onViewCreated phase of the overview frag =\u003e\n   \n   \n        val view: View = inflater.inflate(R.layout.main_fragment, container, false)\n        //gv = view.findViewById\u003cGridView\u003e(R.id.gv)\n        \n        val items = ArrayList\u003cMap\u003cString, Any\u003e\u003e()\n        for (i in img.indices) {\n            val item = HashMap\u003cString, Any\u003e()\n            item[\"image\"] = img[i]\n            item[\"text\"] = label[i]\n            items.add(item)\n        }\n        \n        val kadapter = SimpleAdapter(this.activity,\n                items, R.layout.grid_view_item, arrayOf(\"image\", \"text\"),\n                intArrayOf(R.id.img, txt))\n\n        gv = view.findViewById(R.id.gv)\n\n        this.gv!!.adapter = kadapter\n        this.gv!!.numColumns = 2\n        this.gv!!.onItemClickListener = AdapterView.OnItemClickListener { _, _, position, _ -\u003e\n            Toast.makeText(this.activity, \"selected item：\" + label[position], Toast.LENGTH_SHORT).show()\n            val j = label[position].toString()\n            //val i =  img[position].toInt()\n            // pass param between 2 destinations\n            val bundle = bundleOf(\"j\" to j)\n            //val bundle = bundleOf(\"i\" to i)\n            findNavController().navigate(R.id.action_mainFragment_to_detailFragment, bundle)\n            //findNavController().navigate(action_mainFragment_to_detailFragment)\n\n        }\n        return view\n\n\nRef:\n\nhttps://www.itread01.com/content/1544675943.html (debug)\n\nhttps://proandroiddev.com/migrating-the-deprecated-kotlin-android-extensions-compiler-plugin-to-viewbinding-d234c691dec7 (kotlin-android-extensions is deprecated)\n\nhttps://stackoverflow.com/questions/65185166/disable-kotlin-android-extensions-deprecation-warning kotlin-android-extensions is deprecated)\n\nhttps://developer.android.com/guide/navigation/navigation-pass-data (pass data)\n\nhttps://www.jianshu.com/p/ffa19d26f65f (fragment)\n\nhttps://stackoverflow.com/questions/44214136/what-does-r-drawable-image-return (type cast)\n\nhttps://givemepass.blogspot.com/2011/11/gridview.html (SimpleAdapter \u0026 GridView)\n\nhttp://hk.uwenku.com/question/p-cnphanaq-vu.html (GridView)\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqueeniecplusplus%2Fandroid_review_24","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqueeniecplusplus%2Fandroid_review_24","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqueeniecplusplus%2Fandroid_review_24/lists"}