anyone help me since m beginner to android anyone can give me a code to display 3 edittext to display firstname,middle name and
lastname in another activity on clicking button
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
anyone help me since m beginner to android anyone can give me a code to display 3 edittext to display firstname,middle name and
lastname in another activity on clicking button
Moved to Android section.
You'll get code faster if you use an internet Search engine to find it.give me a code
If you don't understand my answer, don't ignore it, ask a question.
plz but also give me code im getting error see i drag and drop three edit text and one button but wen m pressing button message is coming hello world in second activity y i wnna to display fname mname lastname
Please copy the full text of the error message and paste it here. It has important info about the error.im getting error
If you don't understand my answer, don't ignore it, ask a question.
[
MainActivity.java
package com.example.application;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends Activity implements OnClickListener { public static final String key1 = "mainacativity.key1";
public static final String key2 = "mainacativity.key2";
public static final String key3 = " mainacativity.key3";
EditText e1;
EditText e2;
EditText e3;
Button bt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
e1=(EditText)findViewById(R.id.fname);
e2=(EditText)findViewById(R.id.mname);
e3=(EditText)findViewById(R.id.lname);
bt=(Button)findViewById(R.id.btn);
bt.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i=new Intent(this,NextActivity1.class);
String fname=e1.getText().toString();
String Mname=e2.getText().toString();
String Lname=e3.getText().toString();
i.putExtra(key1, fname);
i.putExtra(key2, Mname);
i.putExtra(key3, Lname);
startActivity(i);
}
}
][
NextActivity1.java
package com.example.application;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.view.Menu;
import android.widget.TextView;
public class NextActivity1 extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_next_activity1);
Intent i=getIntent();
String fname=i.getStringExtra(MainActivity.key1);
String mname=i.getStringExtra(MainActivity.key2);
String lname=i.getStringExtra(MainActivity.key3);
TextView t1=new TextView(this);
TextView t2=new TextView(this);
TextView t3=new TextView(this);
t1.setText("Welcome"+fname);
t2.setText(" Welcome" +mname);
t3.setText("welcome"+lname);
t1.setTextSize(30);
t2.setTextSize(30);
t3.setTextSize(30);
t1.setTextColor(Color.BLUE);
t2.setTextColor(Color.BLUE);
t3.setTextColor(Color.BLUE);
setContentView(t1);
setContentView(t2);
setContentView(t3);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.next_activity1, menu);
return true;
}
}
]
when i click on button its fname lmname,lname not geting display in second activity
Last edited by AJAY KAMBLE; March 27th, 2014 at 11:42 AM.
[
MainActivity.java
package com.example.application;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends Activity implements OnClickListener { public static final String key1 = "mainacativity.key1";
public static final String key2 = "mainacativity.key2";
public static final String key3 = " mainacativity.key3";
EditText e1;
EditText e2;
EditText e3;
Button bt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
e1=(EditText)findViewById(R.id.fname);
e2=(EditText)findViewById(R.id.mname);
e3=(EditText)findViewById(R.id.lname);
bt=(Button)findViewById(R.id.btn);
bt.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i=new Intent(this,NextActivity1.class);
String fname=e1.getText().toString();
String Mname=e2.getText().toString();
String Lname=e3.getText().toString();
i.putExtra(key1, fname);
i.putExtra(key2, Mname);
i.putExtra(key3, Lname);
startActivity(i);
}
}
][
NextActivity1.java
package com.example.application;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.view.Menu;
import android.widget.TextView;
public class NextActivity1 extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_next_activity1);
Intent i=getIntent();
String fname=i.getStringExtra(MainActivity.key1);
String mname=i.getStringExtra(MainActivity.key2);
String lname=i.getStringExtra(MainActivity.key3);
TextView t1=new TextView(this);
TextView t2=new TextView(this);
TextView t3=new TextView(this);
t1.setText("Welcome"+fname);
t2.setText(" Welcome" +mname);
t3.setText("welcome"+lname);
t1.setTextSize(30);
t2.setTextSize(30);
t3.setTextSize(30);
t1.setTextColor(Color.BLUE);
t2.setTextColor(Color.BLUE);
t3.setTextColor(Color.BLUE);
setContentView(t1);
setContentView(t2);
setContentView(t3);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.next_activity1, menu);
return true;
}
}
]
when i click on button its fname lmname,lname not geting display in second activity
--- Update ---
anyone help wen i click on button nothing happen it not go to 2nd0r nextactivity just stay at that page only
Please edit your post and wrap your code with code tags:
[code=java]
YOUR CODE HERE
[/code]
to get highlighting and preserve formatting.
If you don't understand my answer, don't ignore it, ask a question.
since m new i dontknow plz u help
Here are the steps:
1) edit the post
2) insert the following line before the code:
[code]
3) insert the following line after the code:
[/code]
4)save the post
If you don't understand my answer, don't ignore it, ask a question.
wat dou mean by insert the line before the code i just simply copy paste in this tag
I listed 4 steps, which step(s) are you having problems with?
If you don't understand my answer, don't ignore it, ask a question.
MainActivity.java package com.example.application; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; public class MainActivity extends Activity implements OnClickListener { public static final String key1 = "mainactivity.key1"; public static final String key2 = "mainactivity.key2"; public static final String key3 = " mainactivity.key3"; EditText e1; EditText e2; EditText e3; Button bt; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); e1=(EditText)findViewById(R.id.fname); e2=(EditText)findViewById(R.id.mname); e3=(EditText)findViewById(R.id.lname); bt=(Button)findViewById(R.id.btn); bt.setOnClickListener(this); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public void onClick(View arg0) { // TODO Auto-generated method stub Intent i=new Intent(this,NextActivity1.class); String fname=e1.getText().toString(); String Mname=e2.getText().toString(); String Lname=e3.getText().toString(); i.putExtra(key1, fname); i.putExtra(key2, Mname); i.putExtra(key3, Lname); startActivity(i); } } ][ NextActivity1.java package com.example.application; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.graphics.Color; import android.view.Menu; import android.widget.TextView; public class NextActivity1 extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_next_activity1); Intent i=getIntent(); String fname=i.getStringExtra(MainActivity.key1); String mname=i.getStringExtra(MainActivity.key2); String lname=i.getStringExtra(MainActivity.key3); TextView t1=new TextView(this); TextView t2=new TextView(this); TextView t3=new TextView(this); t1.setText("Welcome"+fname); t2.setText(" Welcome" +mname); t3.setText("welcome"+lname); t1.setTextSize(30); t2.setTextSize(30); t3.setTextSize(30); t1.setTextColor(Color.BLUE); t2.setTextColor(Color.BLUE); t3.setTextColor(Color.BLUE); setContentView(t1); setContentView(t2); setContentView(t3); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.next_activity1, menu); return true; } }
Last edited by AJAY KAMBLE; March 27th, 2014 at 02:00 PM.
Ok, that's a good first step.
Now the code has lost all of its formatting. None of the statements are indented to show the logic. All the statements should NOT start in the first column.
Also there are two separate java files mixed in together. It'd be better if each java file was in its own set of code tags.
If you don't understand my answer, don't ignore it, ask a question.
when i click on button its fname ,mname,lname not geting display in second activity --- Update --- anyone help wen i click on button nothing happen it not go to 2nd0r nextactivity just stay at that page only
Putting your comments in code tags makes them harder to read. It'd be better if they were not in code tags.
If you don't understand my answer, don't ignore it, ask a question.
sir m getting not error in this above code but wen i click on button after entering in edittext fname ,mname and lname nothing happen its not moving to nextactivity simply remaining on mainactivity only wen i run my project wen start avd
--- Update ---
plz make any changes if any possible changes in the code so i can get in nextactivity fname ,mname,lname if possible
--- Update ---
sir so watto do now then
Please remove the code tags from your comments and questions. code tags should only go with code.
The code has lost all of its formatting. None of the statements are indented to show the logic. All the statements should NOT start in the first column.
Also there are two separate java files mixed in together. It'd be better if each java file was in its own set of code tags.
If you don't understand my answer, don't ignore it, ask a question.
MainActivity.java package com.example.application; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; public class MainActivity extends Activity implements OnClickListener { public static final String key1 = "mainacativity.key1"; public static final String key2 = "mainacativity.key2"; public static final String key3 = " mainacativity.key3"; EditText e1; EditText e2; EditText e3; Button bt; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); e1=(EditText)findViewById(R.id.fname); e2=(EditText)findViewById(R.id.mname); e3=(EditText)findViewById(R.id.lname); bt=(Button)findViewById(R.id.btn); bt.setOnClickListener(this); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public void onClick(View arg0) { // TODO Auto-generated method stub Intent i=new Intent(this,NextActivity1.class); String fname=e1.getText().toString(); String Mname=e2.getText().toString(); String Lname=e3.getText().toString(); i.putExtra(key1, fname); i.putExtra(key2, Mname); i.putExtra(key3, Lname); startActivity(i); } }
--- Update ---
NextActivity1.java package com.example.application; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.graphics.Color; import android.view.Menu; import android.widget.TextView; public class NextActivity1 extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_next_activity1); Intent i=getIntent(); String fname=i.getStringExtra(MainActivity.key1); String mname=i.getStringExtra(MainActivity.key2); String lname=i.getStringExtra(MainActivity.key3); TextView t1=new TextView(this); TextView t2=new TextView(this); TextView t3=new TextView(this); t1.setText("Welcome"+fname); t2.setText(" Welcome" +mname); t3.setText("welcome"+lname); t1.setTextSize(30); t2.setTextSize(30); t3.setTextSize(30); t1.setTextColor(Color.BLUE); t2.setTextColor(Color.BLUE); t3.setTextColor(Color.BLUE); setContentView(t1); setContentView(t2); setContentView(t3); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.next_activity1, menu); return true; } } ]
The code has lost all of its formatting. None of the statements are indented to show the logic. All the statements should NOT start in the first column.
I guess one out of three is better than none.
If you don't understand my answer, don't ignore it, ask a question.