1

I want display an array of doubles on the android screen, as I would have done in case of C, by using a statement such

for(i=0; i<10; i++)
   printf("a = %d", a[i]);  

I want to make a similar display on the android phone screen. What control is appropriate for this? My problem is not displaying a single variable's value, but multiple values on multiple lines, as I would do on a console in C. The number of lines to be displayed may change during each run of the application. What kind of controls are provided in Android for this?

user13267
  • 6,871
  • 28
  • 80
  • 138
  • Refer the bwlow links http://developer.android.com/reference/android/util/Log.html and usage of log is : http://stackoverflow.com/questions/7959263/android-log-v-log-d-log-i-log-w-log-e-when-to-use-each-one – Pinki Sep 12 '13 at 07:22
  • Doesn't this display it in the logcat, in the IDE or the console? I need something to display it on the android screen, like making a console on the phone's screen – user13267 Sep 12 '13 at 07:24
  • If u want small popup go through the toast concept in android like http://developer.android.com/guide/topics/ui/notifiers/toasts.html else go through the alert dialog concept in android http://www.mkyong.com/android/android-alert-dialog-example/ – Pinki Sep 12 '13 at 07:25
  • for seeing all logcat we have one application in android i,e: https://play.google.com/store/apps/details?id=org.jtb.alogcat&hl=en. in this we have filter option through this we can see only particular application logs only – Pinki Sep 12 '13 at 07:28

1 Answers1

1

This indeed displays into the console (Android = logcat) of the IDE, so that's not what you are describing.

Android is not a command line C program, where any output is automatically send to your screen. You have to do this yourself if you want 'your user' to see anything in the app.

You need to create a view in xml with just a simple textview. Put your output in a string buffer and keep loading it into the textview and you'll see it in your screen.

Since you are trying the above, you probably have no idea what i'm talking about and as then you're missing the whole basics of the system I also can't explain it to you in a simple answer.

Check out good tutorials sites such as http://www.vogella.com/android.html

Stefan de Bruijn
  • 6,289
  • 2
  • 23
  • 31
  • so lets say I have an array, such as a[0] = 0.1 and a[1] = 0.2. I need to display these values on the phone's screen. If I put a single textview on the screen, can I display the two values on two different lines in the text view? Or from the page that you linked, is Listview supposed to be what I am looking for? – user13267 Sep 12 '13 at 07:35
  • A TextView can display multiline texts too - just create a single string from your numbers joining them with a "\n". A ListView would also be possible, you'd have to create an Adapter class providing the values and ListView would display them. – Ridcully Sep 12 '13 at 07:42
  • I wouldn't use a listview for this. A ListView is for click-able stand-alone items like a list of news items. You're easier and better off using a TextView. With a StringBuffer you can easily concinate strings together and indeed \n or whatever like that should work. If it doesn't, you can also tell the TextView to handle the text as if it is HTML. This ofcourse isn't the way you would show info normally, but you're also not showing 'normal info' ;P – Stefan de Bruijn Sep 12 '13 at 08:19