Listview Only One List Entry Play Button Works
I'm trying to make a ListView activity following the example from this website http://cyrilmottier.com/2011/11/23/listview-tips-tricks-4-add-several-clickable-areas/ in which I'm u
Solution 1:
May be you are in wrong way.You have to try this link insted of textView
you have to used button
.
http://wowjava.wordpress.com/2011/03/26/dynamic-listview-in-android/
If you have any problem then let me know.
Solution 2:
Try the below
In getView()
Button b=(Button) convertView.findViewById(R.id.playbutton);
b.setOnClickListener(newOnClickListener()
{
if (position != ListView.INVALID_POSITION) {
startActivity(newIntent("com.fullfrontalgames.numberfighter.Fightattacker"));
}
});
Also you should be using a ViewHolder for smooth scrolling and performance. Details of which are available in the link below.
http://developer.android.com/training/improving-layouts/smooth-scrolling.html
Solution 3:
Update
Sorry for the late update but I sovled this issue on my own by adding a android:onClick attribute to my play button and then defining the public onButtonClick method in my class.
<Button
android:id="@+id/playbutton"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="right"
android:onClick="OnButtonClick"
android:background="@drawable/playbutton" />
Class
publicvoidOnButtonClick(View view){
startActivity(newIntent(
"com.fullfrontalgames.numberfighter.Fightattacker"));
}
Post a Comment for "Listview Only One List Entry Play Button Works"