Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to display the text entered in the text box in the same view

i want to enter the text and then want to display it in the same view like twitter.

I am coding using eclipse juno for android app.

Assistance will be high appreciable

Thanks
Posted
Comments
Richard MacCutchan 20-Feb-15 11:41am    
Assistance will be high appreciable
Assistance with what? All you have told us is what you want to do. But no details of what you have tried, or what problems you have encountered. And where does Twitter come into this question?
Member 11402033 21-Feb-15 0:04am    
I had tried according to this tutorial,
http://developer.android.com/training/basics/firstapp/index.html

all i want is to display the message entered in the text box to be below the text box, i am the the text box, button and message entered to share the same view, as we do it in twitter app or any other messaging app.

1. Add a textview control in the res/layout/activity_my.xml after the EditText control:
<textview>
        android:id="@+id/text_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="" /></textview>

2. add an onclick listener to the Button control:
<button>
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="@string/button_send"
  android:onClick="sendMessage" /></button>


3. Lastly, in the MyActivity.java:
// Called when the user clicks the Send button
public void sendMessage(View view) {

    EditText editText = (EditText) findViewById(R.id.edit_message);
    String message = editText.getText().toString();
    TextView textView = (TextView) findViewById(R.id.text_id);
    textView.setText(message);
}
 
Share this answer
 
Comments
Member 11402033 24-Feb-15 3:17am    
thanks
Member 11402033 24-Feb-15 3:54am    
but the text entered is on the same line of text box and button, i want to occur the entered text below the textbox and button.
please help me
You could add an empty textview below the edittext. When user clicks button you get the text from the edittext and add it to the textview. You can get text from an edittext by typing
Java
edittext.getText().toString();
 
Share this answer
 
Comments
Member 11402033 24-Feb-15 3:18am    
sorry buddy that didn't work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900