Showing
9 changed files
with
138 additions
and
18 deletions
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | package="com.example.vip"> | 3 | package="com.example.vip"> |
| 4 | + | ||
| 4 | <application | 5 | <application |
| 5 | android:allowBackup="true" | 6 | android:allowBackup="true" |
| 6 | android:icon="@mipmap/ic_launcher" | 7 | android:icon="@mipmap/ic_launcher" |
| ... | @@ -8,15 +9,20 @@ | ... | @@ -8,15 +9,20 @@ |
| 8 | android:roundIcon="@mipmap/ic_launcher_round" | 9 | android:roundIcon="@mipmap/ic_launcher_round" |
| 9 | android:supportsRtl="true" | 10 | android:supportsRtl="true" |
| 10 | android:theme="@style/NoActionBar"> | 11 | android:theme="@style/NoActionBar"> |
| 11 | - <activity android:name=".SignInActivity"></activity> | 12 | + <activity android:name=".TestingActivity"></activity> |
| 13 | + <activity android:name=".SignInActivity" /> | ||
| 12 | <activity android:name=".SignUpActivity" /> | 14 | <activity android:name=".SignUpActivity" /> |
| 13 | - <activity android:name=".MainActivity"/> | 15 | + <activity android:name=".MainActivity" /> |
| 14 | - <activity android:name=".SearchActivity"/> | 16 | + <activity android:name=".SearchActivity" /> |
| 15 | - <activity android:name=".SplashActivity" android:theme="@style/SplashTheme"> | 17 | + <activity |
| 18 | + android:name=".SplashActivity" | ||
| 19 | + android:theme="@style/SplashTheme"> | ||
| 16 | <intent-filter> | 20 | <intent-filter> |
| 17 | <action android:name="android.intent.action.MAIN" /> | 21 | <action android:name="android.intent.action.MAIN" /> |
| 22 | + | ||
| 18 | <category android:name="android.intent.category.LAUNCHER" /> | 23 | <category android:name="android.intent.category.LAUNCHER" /> |
| 19 | </intent-filter> | 24 | </intent-filter> |
| 20 | </activity> | 25 | </activity> |
| 21 | </application> | 26 | </application> |
| 27 | + | ||
| 22 | </manifest> | 28 | </manifest> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -12,9 +12,11 @@ import android.view.View | ... | @@ -12,9 +12,11 @@ import android.view.View |
| 12 | import android.widget.Button | 12 | import android.widget.Button |
| 13 | import android.content.Intent | 13 | import android.content.Intent |
| 14 | import android.util.Log | 14 | import android.util.Log |
| 15 | +import androidx.core.content.ContextCompat | ||
| 15 | import com.google.firebase.database.* | 16 | import com.google.firebase.database.* |
| 16 | import com.google.firebase.database.DatabaseReference | 17 | import com.google.firebase.database.DatabaseReference |
| 17 | import com.google.firebase.database.FirebaseDatabase | 18 | import com.google.firebase.database.FirebaseDatabase |
| 19 | +import kotlinx.android.synthetic.main.search.* | ||
| 18 | 20 | ||
| 19 | 21 | ||
| 20 | 22 | ||
| ... | @@ -32,6 +34,9 @@ class SearchActivity : AppCompatActivity() { | ... | @@ -32,6 +34,9 @@ class SearchActivity : AppCompatActivity() { |
| 32 | super.onCreate(savedInstanceState) | 34 | super.onCreate(savedInstanceState) |
| 33 | setContentView(R.layout.search) | 35 | setContentView(R.layout.search) |
| 34 | 36 | ||
| 37 | + val searchList = ArrayList<SearchItem>() | ||
| 38 | + | ||
| 39 | + | ||
| 35 | 40 | ||
| 36 | val searchView: SearchView | 41 | val searchView: SearchView |
| 37 | searchView = findViewById(R.id.searchForm) | 42 | searchView = findViewById(R.id.searchForm) |
| ... | @@ -45,24 +50,26 @@ class SearchActivity : AppCompatActivity() { | ... | @@ -45,24 +50,26 @@ class SearchActivity : AppCompatActivity() { |
| 45 | Toast.makeText(this@SearchActivity, "실패부분 : $query", Toast.LENGTH_SHORT).show() | 50 | Toast.makeText(this@SearchActivity, "실패부분 : $query", Toast.LENGTH_SHORT).show() |
| 46 | } | 51 | } |
| 47 | override fun onDataChange(dataSnapshot: DataSnapshot) { | 52 | override fun onDataChange(dataSnapshot: DataSnapshot) { |
| 48 | - | ||
| 49 | -// 타겟 1개 if (dataSnapshot.exists()){ | ||
| 50 | -// val memo = dataSnapshot.getValue(MemoItem::class.java) | ||
| 51 | -// if (memo != null){ | ||
| 52 | - // Toast.makeText(this@SearchActivity, memo!!.Policy, Toast.LENGTH_SHORT).show() | ||
| 53 | - // } | ||
| 54 | -// | ||
| 55 | -// } | ||
| 56 | for(memoSnapshot in dataSnapshot.children){ | 53 | for(memoSnapshot in dataSnapshot.children){ |
| 57 | val memo = memoSnapshot.getValue(MemoItem::class.java) | 54 | val memo = memoSnapshot.getValue(MemoItem::class.java) |
| 58 | - Toast.makeText(this@SearchActivity, memo!!.Policy, Toast.LENGTH_SHORT).show() | 55 | + |
| 56 | + searchList.add( | ||
| 57 | + SearchItem( | ||
| 58 | + ContextCompat.getDrawable(this@SearchActivity, R.drawable.image01)!!, memo!!.Policy | ||
| 59 | + ) | ||
| 60 | + ) | ||
| 59 | } | 61 | } |
| 62 | + val adapter=SearchAdapter(searchList) | ||
| 63 | + searchRecyclerView.adapter=adapter | ||
| 60 | } | 64 | } |
| 61 | }) | 65 | }) |
| 62 | - Toast.makeText(this@SearchActivity, "검색 처리됨 : $query", Toast.LENGTH_SHORT).show() | 66 | + searchList.clear() |
| 67 | + | ||
| 63 | return true | 68 | return true |
| 64 | } | 69 | } |
| 65 | 70 | ||
| 71 | + | ||
| 72 | + | ||
| 66 | override fun onQueryTextChange(newText: String): Boolean { | 73 | override fun onQueryTextChange(newText: String): Boolean { |
| 67 | // 검색어가 변경되었을 때 이벤트 처리 | 74 | // 검색어가 변경되었을 때 이벤트 처리 |
| 68 | return false | 75 | return false | ... | ... |
| 1 | +package com.example.vip | ||
| 2 | + | ||
| 3 | +import android.content.Intent | ||
| 4 | +import android.system.Os.bind | ||
| 5 | +import android.view.LayoutInflater | ||
| 6 | +import android.view.View | ||
| 7 | +import android.view.ViewGroup | ||
| 8 | +import android.widget.Toast | ||
| 9 | +import androidx.recyclerview.widget.RecyclerView | ||
| 10 | +import kotlinx.android.synthetic.main.item_policyfield.view.* | ||
| 11 | +import kotlinx.android.synthetic.main.item_search.view.* | ||
| 12 | + | ||
| 13 | +class SearchAdapter(private val items: ArrayList<SearchItem>) : | ||
| 14 | + RecyclerView.Adapter<SearchAdapter.ViewHolder>() { | ||
| 15 | + | ||
| 16 | + override fun getItemCount() = items.size | ||
| 17 | + | ||
| 18 | + override fun onBindViewHolder(holder: SearchAdapter.ViewHolder, position: Int) { | ||
| 19 | + val item = items[position] | ||
| 20 | + | ||
| 21 | + holder.apply { | ||
| 22 | + bind(item) | ||
| 23 | + itemView.tag = item | ||
| 24 | + } | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): | ||
| 28 | + SearchAdapter.ViewHolder { | ||
| 29 | + val inflatedView = LayoutInflater.from(parent.context) | ||
| 30 | + .inflate(R.layout.item_search, parent, false) | ||
| 31 | + return SearchAdapter.ViewHolder(inflatedView) | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + class ViewHolder(v: View) : RecyclerView.ViewHolder(v) { | ||
| 35 | + | ||
| 36 | + private var view: View = v | ||
| 37 | + | ||
| 38 | + fun bind(item: SearchItem) { | ||
| 39 | + view.searchIcon.setImageDrawable(item.searchItemImage) | ||
| 40 | + view.searchIconText.text = item.searchItemText | ||
| 41 | + view.setOnClickListener{ | ||
| 42 | + | ||
| 43 | + val intent=Intent(view.context, TestingActivity::class.java) | ||
| 44 | + view.context.startActivity(intent) | ||
| 45 | + } | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +package com.example.vip | ||
| 2 | + | ||
| 3 | +import androidx.appcompat.app.AppCompatActivity | ||
| 4 | +import android.os.Bundle | ||
| 5 | + | ||
| 6 | +class TestingActivity : AppCompatActivity() { | ||
| 7 | + | ||
| 8 | + override fun onCreate(savedInstanceState: Bundle?) { | ||
| 9 | + super.onCreate(savedInstanceState) | ||
| 10 | + setContentView(R.layout.activity_testing) | ||
| 11 | + } | ||
| 12 | +} |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 4 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 5 | + android:layout_width="match_parent" | ||
| 6 | + android:layout_height="match_parent" | ||
| 7 | + tools:context=".TestingActivity"> | ||
| 8 | + | ||
| 9 | +</androidx.constraintlayout.widget.ConstraintLayout> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
vip/app/src/main/res/layout/item_search.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 4 | + android:orientation="horizontal" | ||
| 5 | + android:layout_width="match_parent" | ||
| 6 | + android:layout_height="wrap_content" | ||
| 7 | + android:layout_margin="20dp"> | ||
| 8 | + | ||
| 9 | + | ||
| 10 | + <ImageView | ||
| 11 | + android:id="@+id/searchIcon" | ||
| 12 | + android:layout_width="100dp" | ||
| 13 | + android:layout_height="wrap_content" | ||
| 14 | + android:adjustViewBounds="true"/> | ||
| 15 | + | ||
| 16 | + <TextView | ||
| 17 | + android:id="@+id/searchIconText" | ||
| 18 | + android:layout_width="150dp" | ||
| 19 | + android:layout_height="wrap_content" | ||
| 20 | + android:textSize="20sp"/> | ||
| 21 | + | ||
| 22 | +</LinearLayout> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | xmlns:app="http://schemas.android.com/apk/res-auto" | 3 | xmlns:app="http://schemas.android.com/apk/res-auto" |
| 4 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 4 | android:orientation="vertical" | 5 | android:orientation="vertical" |
| 5 | android:layout_width="match_parent" | 6 | android:layout_width="match_parent" |
| 6 | android:layout_height="match_parent"> | 7 | android:layout_height="match_parent"> |
| ... | @@ -14,4 +15,12 @@ | ... | @@ -14,4 +15,12 @@ |
| 14 | 15 | ||
| 15 | </SearchView> | 16 | </SearchView> |
| 16 | 17 | ||
| 18 | + <androidx.recyclerview.widget.RecyclerView | ||
| 19 | + android:id="@+id/searchRecyclerView" | ||
| 20 | + android:layout_width="match_parent" | ||
| 21 | + android:layout_height="340dp" | ||
| 22 | + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | ||
| 23 | + app:spanCount="3" | ||
| 24 | + app:layout_constraintBottom_toBottomOf="@id/bottom_navigation" | ||
| 25 | + tools:listitem="@layout/item_search" /> | ||
| 17 | </LinearLayout> | 26 | </LinearLayout> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -12,9 +12,9 @@ | ... | @@ -12,9 +12,9 @@ |
| 12 | <string name="title09">빈카테고리</string> | 12 | <string name="title09">빈카테고리</string> |
| 13 | <string name="title10">빈카테고리</string> | 13 | <string name="title10">빈카테고리</string> |
| 14 | 14 | ||
| 15 | - <string name= "alarm">Home</string> | 15 | + <string name="alarm">Home</string> |
| 16 | - <string name= "clock">추천정책</string> | 16 | + <string name="clock">추천정책</string> |
| 17 | - <string name= "timer">찜 목록</string> | 17 | + <string name="timer">찜 목록</string> |
| 18 | - <string name= "stopwatch">내 정보</string> | 18 | + <string name="stopwatch">내 정보</string> |
| 19 | 19 | ||
| 20 | </resources> | 20 | </resources> | ... | ... |
-
Please register or login to post a comment