Solved

Listenser event not responding

Posted on 2012-03-30
5
441 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
  • 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 500 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
custom annotations 9 39
Should localization be done inside spring controller 5 26
hibernate insert example 13 29
Tomcat: Unable to run tomcat service. 2 20
Often, people trade privacy and security for convenience. However in today's concrete jungle, this is an extremely foolish decision considering the vast amount of technologies being used against consumer interest. First off, I won't waste any time e…
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.

810 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