0

I'm a begineer in android. I learned from the developer.android.com, how to display a text by calling another activity. I want to display the user entered text in the same window. i.e., slow the text field(center). please anyone help me. I'm a beginner in android and I have just started to learn android.

mainactivity.java file

public void displayMessage(View view){
        EditText editText = (EditText) findViewById(R.id.edit_message);
        String message = editText.getText().toString();

        // Set the text view as the activity layout
        setContentView(message);
    }

Main Activity.java file. What functionalities should i add to the displayMessage method?

strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">SimpleApp</string>
    <string name="edit_message">Enter Something</string>
    <string name="button_send">Send</string>
    <string name="action_settings">Settings</string>
    <string name="title_activity_main">MainActivity</string>

</resources>
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
sangeetha
  • 47
  • 3
  • 12

1 Answers1

0
//first you need an xml file for the layout that will have 3 widgets      (TextView,EditText,Button)

//in the Activity you implement onclicklistener and in onCreate method
setContentView(R.layout.yourxmlfile);
EditText editText = (EditText) findViewById(R.id.edit_message);
 texxt = (TextView ) findViewById(R.id.text_view);
findViewById.(R.id.your_button).setOnclickListener(this)

@Override
public void onClick(View v){
String message = editText.getText().toString();
texxt.setText(message);
}
cesztoszule
  • 286
  • 3
  • 12
  • I'm a beginner in android and I have just started to learn. I'm learning it from developer.andriod.com site. But I'm not able to follow certain things. So can you suggest me some good sites,for beginners. If there are video tutorials, that will be great.Also y we have to create a xml file and what does widget mean by? I'm sorry for asking such a silly question. But i dono anything in android . So please help me. Thanks in Advance.. – sangeetha Mar 22 '14 at 07:44