开发者

How to set button on listview based on some conditions

开发者 https://www.devze.com 2023-04-01 00:08 出处:网络
I have a ListView with some text, each row contains different length text and I am using CustomAdapter. I want to add a next button to row which is having long text. When I click on that button it sho

I have a ListView with some text, each row contains different length text and I am using CustomAdapter. I want to add a next button to row which is having long text. When I click on that button it should go to another activity and it should show the full te开发者_Python百科xt of the particular row. I am doing like if the text is long I am making the button Visible on that particular row. My problem how to identify the button on particular row and how to set listener for that button. When I click on a particular button, how to get the particular rows data or position.


setOnClickListener over Button in getView() in your CustomAdapter and from there you will get a call for a particular row button........


in getView() itself you have to set the listener of Button and from getView()'s position variable you can get the index...

if(text.length>10)
//button show
//listener
//next activity
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号