![]() |
Android app with Toast Notification . |
Of-course every one know that developing android app is cool ! . Recently in my college i attended the hands on android workshop, session handled by my super senior Dinesh from Star Tech in madurai .
Sessions
1.Overview
2.Installation - Refer developer.android.com to install the eclipse and SDK etc..
3.Let me get started with main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/me" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName" android:text="@string/Prasanna"/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Submit" android:focusableInTouchMode="false"/>
</LinearLayout>
Strings.xml file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">This is Prasanna Vijayan</string>
<string name="app_name">Waybig_pro</string>
<string name="me">Wow this is Cool !</string>
<string name="Submit">Click me</string>
<string name="Prasanna">Prasanna Vijayan</string>
</resources>
MainActivity.java
package com.example;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
EditText ed1;
Button bu1;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ed1 = (EditText)this.findViewById(R.id.editText1);
bu1 = (Button)this.findViewById(R.id.button1);
bu1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
String st1;
st1=ed1.getText().toString();
Toast to1 = Toast.makeText(getApplicationContext(), st1, Toast.LENGTH_LONG);
to1.show();
}
});
}
}
Later : )
No comments:
Post a Comment