0

thi is my code which work fine in blackberry and get 3 responses which show in textview but wheni use this code in android is just show values only 1 times not 3 so how i use 1 text view to print 3 times result??

  for (int x = 7; x <= xmlRespone.length - 1; x = x + 3) {

                    TextView lblTransactionDate = 
  (TextView)     findViewById(R.id.lblTransactionDate);
                    lblTransactionDate.setText("Transaction   
 Date : "+ xmlRespone[x][1]);              





     lblTransactionDate.setTextColor(getResources().getColor
  (R.color.text_color_slateblue));

                    TextView lblAmount = (TextView)   
      findViewById(R.id.lblAmount);
                    lblAmount.setText("Amount : " +    
      xmlRespone[x + 1][1]);
0

2 Answers 2

1

see TextView.append(CharSequence text) for showing all Values in Single TextView.Change your code as:

    TextView lblTransactionDate = (TextView)findViewById(R.id.lblTransactionDate);

    TextView lblAmount = (TextView)findViewById(R.id.lblAmount);

    for (int x = 7; x <= xmlRespone.length - 1; x = x + 3) {
// if you want to clear Prev value
    lblTransactionDate.setText(""); 
    lblTransactionDate.setText("Transaction  Date : "+ xmlRespone[x][1]);        
    // if you want to append with Prev Value
    lblTransactionDate.append("Transaction  Date : "+ xmlRespone[x][1]);      

    lblTransactionDate.setTextColor(getResources().getColor(R.color.text_color_slateblue));

    // if you want to clear Prev value
    lblAmount.setText("Amount : " + xmlRespone[x + 1][1]);
    // if you want to append with Prev Value
    lblAmount.append("Amount : " +  xmlRespone[x + 1][1]);
Sign up to request clarification or add additional context in comments.

Comments

0

Um... the textview will take all three values, but only the last one will remain shown. If you want to append text to it, do

text.setText(text.getText() + "new_text");

Or you could just use

text.append("new_text");

But maybe youjust want to post a 'notification' like message to your user, for which Toast is used for like this

Toast.makeText(context, "Signing in with default user.", Toast.LENGTH_LONG).show();

Just be sure to call the Toast from the UI thread, if not use this

public void fireToast(final String toast)
{
    handler.post(new Runnable()
    {
        @Override
        public void run()
        {
            Toast.makeText(getApplicationContext(), toast, Toast.LENGTH_SHORT).show();
        }
    });
}

1 Comment

Maybe you want to use Toast.makeText(context, "The text you want to show", Toast.LENGTH_LONG).show(); instead of a textview, or use textview's append() instead of setText()...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.