Android
Learn Android with Jnext
Friday, 25 September 2015
How to use the Intent In Andorid
How to use the Intent In Andorid
In this video i explain the how to invoke one activity to other activity by using Intent Object in android.Android WebServices with java Servlet & MySQL by using HttpPost
Android WebServices with java Servlet & MySQL by using HttpPost
Wednesday, 7 January 2015
Make Custom Design For EditText
Custom Design For EditText In Android By using External .Xml file
Have you any question than put your question in comment i will back to you.
Tuesday, 28 October 2014
FatchValueFromEditText
Fatch Value From EditText And Display in TextView
Step:-1 Create New Android Project.
Ex:-
Step :-2 Go to res/layout open activity_main.xml file and Edit it.
:-android Text come from the value/string.xml folder
:-copy below code and paste it you will get the reg layout.
< RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
< TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="@string/Title"
android:textSize="20sp" / >
< TextView
android:id="@+id/msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:text="Your Message" />
< EditText
android:id="@+id/entermsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/msg"
android:hint="Enter Your Message" / >
< Button
android:id="@+id/sub"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="@id/entermsg"
android:layout_centerHorizontal="true"
android:text="Submit"
/>
< /RelativeLayout>
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
< TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="@string/Title"
android:textSize="20sp" / >
< TextView
android:id="@+id/msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:text="Your Message" />
< EditText
android:id="@+id/entermsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/msg"
android:hint="Enter Your Message" / >
< Button
android:id="@+id/sub"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="@id/entermsg"
android:layout_centerHorizontal="true"
android:text="Submit"
/>
< /RelativeLayout>
STEP 3:-Now go to src/MainActivity.java file.
:-get the value based on id that you gave in xml file.
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity implements OnClickListener {
//initialize widget that you need.
TextView yourmsg;
EditText entermsg;
Button submit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/**
* now fatch the id from the activity_main.xml
*/
yourmsg=(TextView)findViewById(R.id.msg);
entermsg=(EditText)findViewById(R.id.entermsg);
submit=(Button)findViewById(R.id.sub);
/**
* now apply the click event when some one click on button.
* you can't get the value before the click event fire.
* if you try to get than u wil get the nullpointer exception.
* implement OnClickListener interface
* now go to onClick() and get the value
*/
submit.setOnClickListener(this);
}
@Override
public void onClick(View v) {
String msg=entermsg.getText().toString();
/**
* now set this value in textview
*/
yourmsg.setText("YOur msg is:="+msg);
}
}
STEP:-4import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity implements OnClickListener {
//initialize widget that you need.
TextView yourmsg;
EditText entermsg;
Button submit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/**
* now fatch the id from the activity_main.xml
*/
yourmsg=(TextView)findViewById(R.id.msg);
entermsg=(EditText)findViewById(R.id.entermsg);
submit=(Button)findViewById(R.id.sub);
/**
* now apply the click event when some one click on button.
* you can't get the value before the click event fire.
* if you try to get than u wil get the nullpointer exception.
* implement OnClickListener interface
* now go to onClick() and get the value
*/
submit.setOnClickListener(this);
}
@Override
public void onClick(View v) {
String msg=entermsg.getText().toString();
/**
* now set this value in textview
*/
yourmsg.setText("YOur msg is:="+msg);
}
}
Now You can Run application on your Emulator You will get the Out Put.
Labels:
Get Value From EditText
Location:
Bhavnagar, Gujarat, India
Subscribe to:
Comments (Atom)



