In your layout use a

  - TextView which describes what you the user should input (lat or
lng)
  - EditText to input some text
  - button which you are done with your input


For example if you are using a LinearLayout/TableLayout for your UI
you could use a  TableRow for the lat and a TableRow for lng

1. Your Layout (not complete!)
----------------------------
....

<TableRow>
<TextView android:text="Lat" android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="14sp"></
TextView>
<EditText android:text="" android:id="@+id/Lat"
android:layout_width="200sp" android:layout_height="wrap_content"></
EditText>
</TableRow>

<TableRow>
<TextView android:text="Lng" android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="14sp"></
TextView>
<EditText android:text="" android:id="@+id/Lng"
android:layout_width="200sp" android:layout_height="wrap_content"></
EditText>
</TableRow>

....

<Button android:text="Ok" android:id="@+id/buttonOk"
android:layout_width="100sp" android:layout_height="wrap_content"
android:layout_gravity="bottom"></Button>

After you are done with defining your layout work on the Activity
class.

2. Activity class

In your Activity you could initiate some member variables which are
referring to the resources you are using in the Layout

The member variables would be

   protected EditText editLat, editLng;
   protected Button buttonOk;


In the onCreate method do something like

   @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.settings);

        editLat = (EditText)findViewById(R.id.Lat);
        editLng = (EditText)findViewById(R.id.Lng);

        buttonOk = (Button)findViewById(R.id.buttonOk);
        ...
}

3. Implement a method onClick() which acts on when you click the OK
button

    public void onClick(View v) {
    //we have only 1 button but in case you have multiple buttons
extend the code!

        if (v.getId() == buttonOk.getId()) {

           Log.d("TEST","Lng: "+ editLng.toString()  ); // access your
text input prints the Lng in the logcat
           Log.d("TEST","Lat:" + editLat.toString()  ); // "
"                 "         Lat          "

            }
        }


    }


If you want to share the input information with another activity in
your application you could use SharedPreference.


I hope this answers your question.

--
Roman Baumgaertner
Sr. SW Engineer-OSDC
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.



On Jul 23, 1:25 am, Bibrak Qamar <[email protected]> wrote:
> Hi all,
>
> I have to input text from user ( lat and lng ) and use them to geocode.
> Please help me how to drive user to a textbox and get input then click a
> button where i can perform the event.
>
> I have found out a way how to add-listeners using a botton, but have no idea
> how to take input from textbox and use it in my event.
>
> I will appreciate any help from u huys out there.
>
> Thanks
> regards
> --
> Bibrak Qamar
> NUST-SEECS
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to