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
Solved

Android error while creating dynamic row

Posted on 2012-03-29
3
540 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: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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
You should read OS supplied guidelines before developing. I can't stress that enough. The guidelines will help you understand the reasons mobile app developers do what they do.  Apple is very particular when they review appstore submissions.
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…

808 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