Toggle navigation
Toggle navigation
This project
Loading...
Sign in
신기성
/
WELLO
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Authored by
신기성
2019-10-23 23:22:44 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c82d90e14e8977dc5f81752a8044cba9a938b353
c82d90e1
1 parent
8594dc06
viewpager demo create
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
5 deletions
vip/app/src/main/java/com/example/vip/SignInActivity.kt
vip/app/src/main/java/com/example/vip/ViewPagerAdapter.kt
vip/app/src/main/res/layout/activity_signin.xml
vip/app/src/main/res/layout/viewpager_activity.xml
vip/app/src/main/java/com/example/vip/SignInActivity.kt
View file @
c82d90e
...
...
@@ -3,10 +3,12 @@ package com.example.vip
import
android.os.Bundle
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.content.ContextCompat
import
androidx.viewpager.widget.ViewPager
import
kotlinx.android.synthetic.main.activity_signin.*
class
SignInActivity
:
AppCompatActivity
()
{
internal
lateinit
var
viewpager
:
ViewPager
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_signin
)
...
...
@@ -27,6 +29,9 @@ class SignInActivity : AppCompatActivity() {
val
adapter
=
PolicyFieldAdapter
(
policyFieldList
)
policyFieldRecyclerView
.
adapter
=
adapter
viewpager
=
findViewById
(
R
.
id
.
viewpager
)
as
ViewPager
val
viewpageradapter
=
ViewPagerAdapter
(
this
)
viewpager
.
adapter
=
viewpageradapter
}
...
...
vip/app/src/main/java/com/example/vip/ViewPagerAdapter.kt
0 → 100644
View file @
c82d90e
package
com.example.vip
import
android.content.Context
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
androidx.viewpager.widget.PagerAdapter
import
androidx.viewpager.widget.ViewPager
class
ViewPagerAdapter
(
private
val
context
:
Context
)
:
PagerAdapter
()
{
private
var
layoutInflater
:
LayoutInflater
?
=
null
val
Image
=
arrayOf
(
R
.
drawable
.
image01
,
R
.
drawable
.
image02
,
R
.
drawable
.
image03
)
override
fun
isViewFromObject
(
view
:
View
,
`object`
:
Any
):
Boolean
{
return
view
===
`object`
}
override
fun
getCount
():
Int
{
return
Image
.
size
}
override
fun
instantiateItem
(
container
:
ViewGroup
,
position
:
Int
):
Any
{
layoutInflater
=
context
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
)
as
LayoutInflater
val
v
=
layoutInflater
!!
.
inflate
(
R
.
layout
.
viewpager_activity
,
null
)
val
image
=
v
.
findViewById
<
View
>(
R
.
id
.
imageview
)
as
ImageView
image
.
setImageResource
(
Image
[
position
])
val
vp
=
container
as
ViewPager
vp
.
addView
(
v
,
0
)
return
v
}
override
fun
destroyItem
(
container
:
ViewGroup
,
position
:
Int
,
`object`
:
Any
)
{
val
vp
=
container
as
ViewPager
val
v
=
`object`
as
View
vp
.
removeView
(
v
)
}
}
\ No newline at end of file
vip/app/src/main/res/layout/activity_signin.xml
View file @
c82d90e
...
...
@@ -19,11 +19,16 @@
android:layout_height=
"50dp"
android:text=
"로고 및 검색창"
/>
<TextView
android:id=
"@+id/space_rollingBanner"
android:layout_width=
"match_parent"
android:layout_height=
"200dp"
android:text=
"롤링배너창"
/>
<androidx.viewpager.widget.ViewPager
android:id=
"@+id/viewpager"
android:layout_width=
"436dp"
android:layout_height=
"220dp"
app:layout_constraintStart_toStartOf=
"parent"
android:layout_marginStart=
"8dp"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
android:layout_marginEnd=
"8dp"
>
</androidx.viewpager.widget.ViewPager>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/policyFieldRecyclerView"
...
...
vip/app/src/main/res/layout/viewpager_activity.xml
0 → 100644
View file @
c82d90e
<?xml version="1.0" encoding="utf-8"?>
<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:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ImageView
android:id=
"@+id/imageview"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
tools:srcCompat=
"@tools:sample/avatars"
/>
</LinearLayout>
\ No newline at end of file
Please
register
or
login
to post a comment