Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old February 4th, 2010, 10:52 PM   #1 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Jan 2010
Location: mumbai(India)
Posts: 22
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default EditText return null

Hello everybody,

I had write one application which takes data from user as a input field and store that into string varible but when I tried to ptint that String varible it gives me null.

my Test1.java is like
Code:
package
com.micro;
import
android.app.Activity;
import
android.app.PendingIntent;
import
android.content.BroadcastReceiver;
import
android.content.Context;
import
android.content.Intent;
import
android.content.IntentFilter;
import
android.os.Bundle;
import
android.telephony.gsm.SmsManager;
import
android.view.View;
import
android.view.View.OnClickListener;
import
android.widget.Button;
import
android.widget.EditText;
import
android.widget.Toast;
public
class Test1 extends Activity { EditText name1,no1; Button ok; String nm,mob1; intmob; /**Calledwhentheactivityisfirstcreated.*/
@Override
publicvoid onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); name1 = (EditText)findViewById(R.id.name); no1 = (EditText)findViewById(R.id.no); Button ok = (Button)findViewById(R.id.ok); nm = name1.getText().toString(); mob1 = no1.getText().toString(); // mob = Integer.parseInt(no.getText().toString()); ok.setOnClickListener(okListener); print(); } private OnClickListener okListener = new OnClickListener() { publicvoid onClick(View v) { sendSMS("9960510915",nm+"......."+mob1); } }; publicvoid print() { System.out.println ("name is"+nm); System.out.println ("Mobile no is"+mob); } publicvoid sendSMS(String phoneNumber, String message)
{ //send message } }
//main.xml is

Code:
<?xml version="1.0" encoding="utf-8"?> <AbsoluteLayout android:id="@+id/widget0" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" > <LinearLayout android:id="@+id/widget28" android:layout_width="252px" android:layout_height="340px" android:orientation="vertical" android:layout_x="36px" android:layout_y="31px" > <TextView android:id="@+id/widget29" android:layout_width="226px" android:layout_height="44px" android:text="Name" > </TextView> <EditText android:id="@+id/name" android:layout_width="225px" android:layout_height="44px" android:text="EditText" android:textSize="18sp" > </EditText> <TextView android:id="@+id/widget31" android:layout_width="223px" android:layout_height="40px" android:text="Mob No" > </TextView> <EditText android:id="@+id/no" android:layout_width="226px" android:layout_height="48px" android:textSize="18sp" > </EditText> <Button android:id="@+id/ok" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Ok" > </Button> </LinearLayout> </AbsoluteLayout>
why EditText return null?

Advertisements
pramod.deore is offline  
Reply With Quote
sponsored links
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 03:37 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.