Set basic onClickListener
This commit is contained in:
parent
7f8d8738f8
commit
dec94b0011
|
@ -3,7 +3,8 @@
|
||||||
<component name="DesignSurface">
|
<component name="DesignSurface">
|
||||||
<option name="filePathToZoomLevelMap">
|
<option name="filePathToZoomLevelMap">
|
||||||
<map>
|
<map>
|
||||||
<entry key="app/src/main/res/layout/activity_main.xml" value="0.2" />
|
<entry key="app/src/main/res/layout/activity_image_viewer.xml" value="0.26132246376811596" />
|
||||||
|
<entry key="app/src/main/res/layout/activity_main.xml" value="0.33" />
|
||||||
<entry key="app/src/main/res/layout/fragment_image_grid.xml" value="0.2515625" />
|
<entry key="app/src/main/res/layout/fragment_image_grid.xml" value="0.2515625" />
|
||||||
<entry key="app/src/main/res/layout/image_grid_item.xml" value="0.35260416666666666" />
|
<entry key="app/src/main/res/layout/image_grid_item.xml" value="0.35260416666666666" />
|
||||||
</map>
|
</map>
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package com.example.testes
|
package com.example.testes
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -51,10 +53,17 @@ class ImageGridFragment(val images: List<BooruImage>) : Fragment() {
|
||||||
.load(imageList[position].preview_url)
|
.load(imageList[position].preview_url)
|
||||||
.placeholder(ContextCompat.getDrawable(context, R.drawable.ic_launcher_foreground))
|
.placeholder(ContextCompat.getDrawable(context, R.drawable.ic_launcher_foreground))
|
||||||
.into(holder.imageview)
|
.into(holder.imageview)
|
||||||
|
|
||||||
|
holder.imageview.setOnClickListener(holder)
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), View.OnClickListener {
|
||||||
var imageview: ImageView = itemView.findViewById(R.id.image)
|
var imageview: ImageView = itemView.findViewById(R.id.image)
|
||||||
|
|
||||||
|
override fun onClick(view: View?) {
|
||||||
|
val intent = Intent(view?.context, ImageViewerActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int = imageList.size
|
override fun getItemCount(): Int = imageList.size
|
||||||
|
|
|
@ -2,10 +2,16 @@ package com.example.testes
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import com.example.testes.databinding.ActivityImageViewerBinding
|
||||||
|
import com.example.testes.databinding.ActivityMainBinding
|
||||||
|
|
||||||
class ImageViewerActivity : AppCompatActivity() {
|
class ImageViewerActivity : AppCompatActivity() {
|
||||||
|
lateinit var binding: ActivityImageViewerBinding
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_image_viewer)
|
binding = ActivityImageViewerBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,4 +6,10 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".ImageViewerActivity">
|
tools:context=".ImageViewerActivity">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:src="@mipmap/ic_launcher"
|
||||||
|
/>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -24,7 +24,7 @@
|
||||||
android:id="@+id/search"
|
android:id="@+id/search"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:iconifiedByDefault="false"
|
app:iconifiedByDefault="false"
|
||||||
android:queryBackground="@android:color/transparent"
|
android:queryBackground="@android:color/transparent"
|
||||||
|
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue