Solved

Android error while creating dynamic row

Posted on 2012-03-29
3
542 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
[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
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:Santhana
Santhana 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Working settings for French ISP Orange "Prêt à Surfer" SIM cards for data connections only. Can't be found anywhere else !
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.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

724 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