Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Listenser event not responding

Posted on 2012-03-30
5
Medium Priority
?
459 Views
Last Modified: 2012-04-02
Hello there,

i have 2 buttons created and have setOnClickListeners on them. the addProduct_button is responding properly. but the delete button is not working as required.only the last row gets deleted when i clcik on the delete button. what am i doing wrong.please help.i have attached my code.

cheers
Zolf
Order.java
0
Comment
Question by:zolf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 8

Expert Comment

by:Santhana
ID: 37794572
Hi zolf,

First declare this TableRow  tr & Button delete_Button  as locale variable.... I guess while adding rows dynamically  the id we are assigning to the view creating problem.(I too have little skeptic about assigning  ids to a view)...


Change  your code like this ...

private void createRow(int qty2, String productSelected2)
{
   final TableRow  tr = new TableRow(this);  

   Button delete_Button = new Button(this);  
    delete_Button .setLayoutParams(lRowParam );
   delete_Button.setGravity( Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
   delete_Button.setText("Delete");
   delete_Button.setTextSize(10);
   delete_Button.setHeight(5);
   tr.addView(delete_Button);

}
0
 

Author Comment

by:zolf
ID: 37794637
santhanasamy,

thnaks for your help once again.

>>I too have little skeptic about assigning  ids to a view
what do you suggest,is there another better way out.
0
 
LVL 8

Accepted Solution

by:
Santhana earned 2000 total points
ID: 37794697
Hi zolf,

Please refer this link...
http://stackoverflow.com/questions/1714297/android-view-setidint-id-programmatically-how-to-avoid-id-conflictsAccording to View documentation

The identifier does not have to be unique in this view's hierarchy. The identifier should be a positive number.
So we can use any positive integer you like, but in this case there can be some views with equivalent id's.
If we want to search for some view in hierarchy calling to setTag with some key objects may be handy.

Is there another better way out??
We can define ids.xml in res/values. You can see an exact example in android's sample code.

samples/ApiDemos/src/com/example/android/apis/RadioGroup1.java samples/ApiDemp/res/values/ids.xml
0
 

Author Closing Comment

by:zolf
ID: 37794832
thanks a lot
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is a lot to be said for protecting yourself and your accounts with 2 factor authentication.  I found to my own chagrin, that there is a big downside as well.
Learn how to use the free Acronis True Image app to easily transfer data between iPhones and Android phones.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question