Solved

Android error while creating dynamic row

Posted on 2012-03-29
3
530 Views
Last Modified: 2012-03-29
hello there,

i have an activity which takes some user input and when the user clicks the add  button,the input should get added to table row.but i get error when i try to add.i am able to get the table header,but cannot show input record.i have attached the error log and the code.please help.

cheers
zolf
log.txt
Order.java
0
Comment
Question by:zolf
3 Comments
 
LVL 1

Accepted Solution

by:
garikapatisuresh earned 300 total points
ID: 37781004
Dear zolf,

Based on your attached log and the code I identified the problem.

in createRow(int qty2, String productSelected2) method, you are trying to set qty2 as a resource id to the TextView labelDATE. But the qty2 is not a raw string resource defined in your res folder. Here qty2 hold the value of qty_text_input TextView value.

Hence the labelDATE TextView is trying to find a string with the given integer value. But it was not able to identify any where. Hence crash occured.

Probably what you have to do is, you have to use TextView's one more polymorphic method setText(String).

I mean, in createRow(--) method,

use
labelDATE.setText(qty2+""); or labelDATE.setText(Integer.toString(qty2));
instead of
labelDATE.setText(qty2);

All the best...
0
 
LVL 8

Assisted Solution

by:santhanasamy
santhanasamy earned 200 total points
ID: 37781016
Hi Zlof,

In onClick() method  you are getting the string from the EditText and then converting that string into Integer.
In  createRow() method you are trying to access the string rresource by using this integer
This is not a string resource. It is just a String

So change the code like this....

      try{
            Log.d("ZAJ", qty_text_input.getText().toString());
//               qty = Integer.parseInt(qty_text_input.getText().toString());      
                                 }
            catch (NumberFormatException ex)
            {
               // 'price' does not contain a valid integer
                  ex.printStackTrace();
            }
            createRow(qty_text_input.getText().toString() ,productSelected);
              }



private void createRow(String qty2, String productSelected2)
{
.............
      TextView labelDATE = new TextView(this);
       labelDATE.setId(200+count);
       labelDATE.setText(qty2);

...........
}
0
 

Author Closing Comment

by:zolf
ID: 37783198
cheers
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

If you are anything like me, you install many apps on your phone and have your life on it, sometimes literally.  When I bought my current phone, a Samsung Galaxy S5 from Verizon, they were only selling the versions with 16 GB internal.  I didn't rea…
Introduction This article is a continuation of Part-1 as evident from the title. Please visit this page (http://www.experts-exchange.com/articles/18706/Backing-up-personal-data-on-your-Android-device-Part-1.html) to read the earlier Part -1. If y…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now