LAB AND.docx - Experiment 1 Create a basic Android application for Hello World MainActivity.java package com.example.helloworld import android.os.Bundle

LAB AND.docx - Experiment 1 Create a basic Android...

This preview shows page 1 - 4 out of 41 pages.

Experiment 1 Create a basic Android application for Hello World MainActivity.java package com.example.helloworld; import android.os.Bundle; import android.app.Activity; import android.view.Menu; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } activity_main.xml < RelativeLayout xmlns:android = "" xmlns:tools = "" android:layout_width = "match_parent" android:layout_height = "match_parent" android:paddingBottom = "@dimen/activity_vertical_margin" android:paddingLeft = "@dimen/activity_horizontal_margin" android:paddingRight = "@dimen/activity_horizontal_margin" android:paddingTop = "@dimen/activity_vertical_margin" tools:context = ".MainActivity" > < TextView android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "@string/hello_world" /> </ RelativeLayout > Experiment 2 Write an Android app for Welcome User. MainActivity.java package com.example.welcomerohan; import android.app.Activity; import android.os.Bundle; import android.view.View; 1
Image of page 1
import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class MainActivity extends Activity implements OnClickListener{ Button b1 ; TextView tv ; @Override protectedvoid onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout. activity_main ); tv = (TextView)findViewById(R.id. textView1 ); b1 = (Button)findViewById(R.id. button1 ); b1 .setOnClickListener( this ); } @Override publicvoid onClick(View arg0) { tv .setText( "Welcome Rohan" ); } } activity_main.xml < LinearLayout xmlns:android = "" xmlns:tools = "" android:id = "@+id/LinearLayout1" android:layout_width = "match_parent" android:layout_height = "match_parent" android:orientation = "vertical" android:paddingBottom = "@dimen/activity_vertical_margin" android:paddingLeft = "@dimen/activity_horizontal_margin" android:paddingRight = "@dimen/activity_horizontal_margin" android:paddingTop = "@dimen/activity_vertical_margin" tools:context = ".MainActivity" > < TextView android:id = "@+id/textView1" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "TextView" /> < Button android:id = "@+id/button1" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "@string/c" /></ LinearLayout > Experiment 3 Write an Android App using CheckBox for generating Bill MainActivity.java package com.example.checkbox; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.CheckBox; import android.widget.TextView; import android.widget.Toast; 2
Image of page 2
public class MainActivity extends Activity implements OnClickListener { CheckBox checkBox1,checkBox2,checkBox3,checkBox4; Button b1; TextView textView1,textView2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView1 = (TextView)findViewById(R.id.textView1);
Image of page 3
Image of page 4

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture