Reputation: 9216
I want to have a ListView that have an image in every item (star) and that image is clickabe. In other word user can click on star of every row of ListView and I want to define click action for that. How I can do this?
Upvotes: 2
Views: 2357
Reputation: 13501
Add an imageView.. make it clickable by adding this to your ImageView tag:
android:clickable="true"
android:focusable = "false"
Upvotes: 3
Reputation: 22637
You can use an ImageButton,
http://developer.android.com/reference/android/widget/ImageButton.html
You can also simply make the image clickable, and set it's onClickListener(),
The problem with this however is that there will be no visual feedback to the user as the image is clicked. An image button looks and acts like a button, and if you are willing to provide normal, pressed, etc versions of the image, you can attach a state list drawable to the image button to make it look very professional.
http://developer.android.com/reference/android/graphics/drawable/StateListDrawable.html
Upvotes: 0
Reputation: 603
you can make a ImageButton like
<ImageButton
android:id="@+id/sound_button"
android:layout_x="430px"
android:layout_y="219px"
android:layout_width="48px "
android:layout_height="48px"
android:scaleType="center"
android:src="@android:drawable/volumeicon"
android:background="@drawable/clearbuttonup"
/>
and make a new xml and name it selector
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/button_pressed" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/button_focused" /> <!-- focused -->
<item android:drawable="@drawable/button_normal" /> <!-- default -->
</selector>
OR you make a Imageview and setproperty of that ImageView isClickable="true"
Upvotes: 2