Get data from EditText and writing it to screen

Put your problem here if it does not fit any of the other categories.

Get data from EditText and writing it to screen

Postby alexa-lol » Thu Apr 29, 2010 5:36 pm

hej :) I am a novice Android programmer... and have found myself in a bit of troubles...
I have:
package com.example.helloandroid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

HelloAndroid.java
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class HelloAndroid extends Activity {
  2.  
  3.     /** Called when the activity is first created. */
  4.  
  5.     @Override
  6.  
  7.     public void onCreate(Bundle savedInstanceState) {
  8.  
  9.         super.onCreate(savedInstanceState);
  10.  
  11.         setContentView(R.layout.main);
  12.  
  13.     }
  14.  
  15. }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


and

Main.xml

and
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.    android:layout_width="fill_parent"
  6.  
  7.    android:layout_height="fill_parent">
  8.  
  9.     <TextView
  10.  
  11.        android:id="@+id/label"
  12.  
  13.        android:layout_width="fill_parent"
  14.  
  15.        android:layout_height="wrap_content"
  16.  
  17.        android:text="Insert number"/>
  18.  
  19.     <EditText
  20.  
  21.        android:id="@+id/entry"
  22.  
  23.        android:layout_width="fill_parent"
  24.  
  25.        android:layout_height="wrap_content"
  26.  
  27.        android:background="@android:drawable/editbox_background"
  28.  
  29.        android:layout_below="@id/label"/>
  30.  
  31.     <Button
  32.  
  33.        android:id="@+id/reverse"
  34.  
  35.        android:layout_width="wrap_content"
  36.  
  37.        android:layout_height="wrap_content"
  38.  
  39.        android:layout_below="@id/entry"
  40.  
  41.        android:layout_alignParentRight="true"
  42.  
  43.        android:layout_marginLeft="10dip"
  44.  
  45.        android:text="Reverse" />
  46.  
  47.     <TextView
  48.  
  49.        android:id="@+id/reverse"
  50.  
  51.        android:layout_width="fill_parent"
  52.  
  53.        android:layout_height="wrap_content"
  54.  
  55.        android:layout_below="@id/reverse"
  56.  
  57.        android:text="Reverse number is: "/>
  58.  
  59. </RelativeLayout>
Parsed in 0.004 seconds, using GeSHi 1.0.8.4


This displays this:
Image

I also have a method which reverses the number
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.     private static int reverseNumber(int number, int temp) {
  2.  
  3.         if(number==0){
  4.  
  5.             return temp;
  6.  
  7.         } else{
  8.  
  9.             return reverseNumber(number/10, temp*10 + number%10);
  10.  
  11.         }
  12.  
  13.     }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


How would I make:
-Read number from EditText entry
-Apply reverseNumber method
-Show result on screen

I can't find the answer...

help
thanks
alexa-lol
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Apr 29, 2010 5:23 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 20 guests