开发者

start a new activity from button click within listview (using simplecursoradapter)

I have a listview which I am populating with a custom SimpleCursorAdapter, each row contains a button which, when clicked should open a new activity and pass the ID of the ori开发者_JS百科ginal data object so I can display the related image on screen.

I am having problems implementing the onclick event for the button and I understand you can only use startActivity() within an activity - is this correct? if so, is there a workaround as my cursoradapter code is in it's own class which extends SimpleCursorAdapter (ie. not in an activity!)

Just one more question if I may? - how can I pass the dataobject ID (ImageID) of the button clicked to the new activity?


set click listener over Button in getView() method in your adapter and use startActivity from there.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜