Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Android
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Android
need to add onclick event programtically
shawn peter
Ranch Hand
Posts: 1325
1
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
below is my method to add textviews proramatically.Based on the number of elements it adds the Textviews.I need to add onclick event for all of them.How to do this ?
void Show() { getMember(); //Iterator<String> itr = members.iterator(); Iterator<String> itr = teamMembers.iterator(); while (itr.hasNext()) { TableRow productionmorning = new TableRow(this); productionmorning.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); TextView prodttext = new TextView(this); prodttext.setBackgroundDrawable(getResources().getDrawable( R.drawable.borderblueshedule)); prodttext.setText(itr.next()); prodttext.setTextColor(Color.WHITE); prodttext.setGravity(Gravity.CENTER); // labelTV.setTextColor(Color.WHITE); prodttext.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); productionmorning.addView(prodttext); TableRow.LayoutParams params = new TableRow.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.height = 40; params.width = 150; params.setMargins(80, 0, 0, 0); prodttext.setLayoutParams(params); tl.addView(productionmorning, new TableLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); } }
Ulf Dittmer
Rancher
Posts: 43081
77
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Surely you have added onClick handlers in previous code of yours? What is different about this code?
Edit: Yes, you have, e.g. right here:
https://coderanch.com/t/626478/Android/Mobile/intent-activity-activity-killed
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
header cover by the scrollview
how to remove old values in my table
how to select table row by clicking
why TextView not center
How to add a textview dynamically in a table row in table layout
More...