0% found this document useful (0 votes)
40 views

Androidone

The document contains code for an Android application with a linear layout. It includes an EditText field for user input, a button, and code to display a toast message with the text from the EditText field when the button is clicked. The layout places the EditText and button in a vertical linear layout to fill the parent view. Strings for the captions are defined in a resources file. When the button is clicked, the onClick method gets the text from the EditText, creates a toast message with "Hello" and that text, and displays the toast.

Uploaded by

abhishek0988
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Androidone

The document contains code for an Android application with a linear layout. It includes an EditText field for user input, a button, and code to display a toast message with the text from the EditText field when the button is clicked. The layout places the EditText and button in a vertical linear layout to fill the parent view. Strings for the captions are defined in a resources file. When the button is clicked, the onClick method gets the text from the EditText, creates a toast message with "Hello" and that text, and displays the toast.

Uploaded by

abhishek0988
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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

>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText

android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/textviewcaption"

android:id="@+id/name"

/>
<Button

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/goButtoncaption"
android:id="@+id/fshowButton"
/>
</LinearLayout>

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


<resources>
<string name="hello">Hello World, FirstActivity!</string>
<string name="app_name">MyFirstAndroidApplication</string>

<string name="textviewcaption">type your name</string>


<string name="goButtoncaption">go</string>
</resources>
package thinking.machine;

import java.util.jar.Attributes.Name;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
private Button fshowButton;
private EditText name;

public class MainActivity extends Activity {


/** Called when the activity is first created. */
fshowButton=(Button)this.findViewById(R.id.fshowButton);
name=(EditText)this.findViewById(R.id.name);
fshowButton.setOnClickListener(new OnClickListener())
{
@Override
public void onClick(view v)
{
msg=Name.getText().tostring();
Toast.makeText(MainActivity.this,"hello "+msg,Toast.LENGTH_LONG)
show();
}
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
};

You might also like