This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override fun instantiateItem(container: ViewGroup, position: Int): Any { | |
| layoutInflater = LayoutInflater.from(context) | |
| val view: View = layoutInflater.inflate(R.layout.viewpageritem, container, false) | |
| val imageView: ImageView | |
| val title: TextView | |
| val content: TextView | |
| imageView = view.findViewById(R.id.imageview) | |
| title = view.findViewById(R.id.title) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dependencies{ | |
| implementation 'com.android.volley:volley:1.2.0' | |
| implementation 'com.github.bumptech.glide:glide:4.12.0' | |
| annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <uses-permission android:name="android.permission.INTERNET"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <LinearLayout 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" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:orientation="vertical" | |
| tools:context=".MainActivity"> | |
| <androidx.viewpager.widget.ViewPager | |
| android:layout_width="match_parent" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:orientation="vertical"> | |
| <ImageView | |
| android:id="@+id/imageview" | |
| android:layout_width="match_parent" | |
| android:layout_height="250dp" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class ViewPagerModel(var title: String, var content: String, var image: String) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Adapter: PagerAdapter { | |
| var vPagerModel: List<ViewPagerModel> | |
| lateinit var layoutInflater: LayoutInflater | |
| var context: Context | |
| constructor(model: List<ViewPagerModel>, context: Context): super() { | |
| this.vPagerModel = model | |
| this.context = context | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private lateinit var viewPager : ViewPager | |
| private lateinit var adapter: Adapter | |
| private lateinit var model: MutableList<ViewPagerModel> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| model = ArrayList<ViewPagerModel>() | |
| viewPager = findViewById(R.id.viewPager) | |
| adapter = Adapter(model as ArrayList<ViewPagerModel>, applicationContext) | |
| viewPager.adapter = adapter | |
| request() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MainActivity : AppCompatActivity() { | |
| private lateinit var viewPager : ViewPager | |
| private lateinit var adapter: Adapter | |
| private lateinit var model: MutableList<ViewPagerModel> | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| model = ArrayList<ViewPagerModel>() |
OlderNewer