All Imp Mad Programs
All Imp Mad Programs
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</[Link]>
Java code
package [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
}
}
2 Develop an android application to place Name, Age and Mobile
number on the display screen using Absolute Layout
Xml file
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
tools:context=".MainActivity">
<TextView
android:id="@+id/tvName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="40dp"
android:layout_y="20dp"
android:text="@string/name"
android:textSize="30sp" />
<TextView
android:id="@+id/tvAge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="40dp"
android:layout_y="70dp"
android:text="@string/age"
android:textSize="30sp" />
<TextView
android:id="@+id/tvMobileNo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="40dp"
android:layout_y="120dp"
android:text="@string/mobile_no"
android:textSize="30sp" />
</AbsoluteLayout>
Java file
package [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
}
}
[Link]
<resources>
<string name="app_name">AbsoluteLayout</string>
<string name="name">Name : Suraj Pande</string>
<string name="age">Age : 26</string>
<string name="mobile_no">Mobile No. : 9851236547</string>
</resources>
Xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
tools:context=".MainActivity">
<TextView
android:id="@+id/tvName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/name"
android:textSize="40sp" />
<TextView
android:id="@+id/tvAge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/age"
android:textSize="40sp" />
<TextView
android:id="@+id/tvMobileNo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/mobile_no"
android:textSize="40sp" />
</LinearLayout>
Java file
package [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
}
}
[Link]
<resources>
<string name="app_name">LinearLayout</string>
<string name="name">Name : Suraj Pande</string>
<string name="age">Age : 26</string>
<string name="mobile_no">Mobile No. : 9851236547</string>
</resources
Xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
tools:context=".MainActivity">
<TextView
android:id="@+id/studName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Student name: Amol Chaudhari"
android:textSize="24sp" />
<TextView
android:id="@+id/studMarks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Marks: 75.00"
android:textSize="24sp" />
</LinearLayout>
Java file
package [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
}
}
Xml file
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/table_heading"
android:gravity="center_horizontal"
android:padding="10dp"
android:textColor="@android:color/black"
android:textStyle="bold"/>
<TableRow
android:id="@+id/headings"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#607D8B"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:layout_weight="1"
android:textColor="@android:color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dept"
android:layout_weight="1"
android:textColor="@android:color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="City"
android:layout_weight="1"
android:textColor="@android:color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Percentage"
android:layout_weight="1"
android:textColor="@android:color/white"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E7E7EB"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s1_name"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s1_dept"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s1_city"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s1_percentage"
android:layout_weight="1"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s2_name"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s2_dept"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s2_city"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s2_percentage"
android:layout_weight="1"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E7E7EB"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s3_name"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s3_dept"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s3_city"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s3_percentage"
android:layout_weight="1"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s4_name"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s4_dept"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s4_city"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s4_percentage"
android:layout_weight="1"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E7E7EB"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s5_name"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s5_dept"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s5_city"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s5_percentage"
android:layout_weight="1"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s6_name"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s6_dept"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s6_city"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s6_percentage"
android:layout_weight="1"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E7E7EB"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s7_name"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s7_dept"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s7_city"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s7_percentage"
android:layout_weight="1"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s8_name"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s8_dept"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s8_city"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s8_percentage"
android:layout_weight="1"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E7E7EB"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s9_name"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s9_dept"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s9_city"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s9_percentage"
android:layout_weight="1"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s10_name"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s10_dept"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s10_city"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/s10_percentage"
android:layout_weight="1"/>
</TableRow>
</TableLayout>
Java file
package [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
}
}
[Link]
<resources>
<string name="app_name">TableLayout</string>
<string name="table_heading">Students Basic Information</string>
<string name="s1_name">Rohit</string>
<string name="s1_dept">COMP</string>
<string name="s1_city">Pune</string>
<string name="s1_percentage">85.21</string>
<string name="s2_name">Amit</string>
<string name="s2_dept">E & TC</string>
<string name="s2_city">Mumbai</string>
<string name="s2_percentage">75.26</string>
<string name="s3_name">Rohan</string>
<string name="s3_dept">COMP</string>
<string name="s3_city">Nashik</string>
<string name="s3_percentage">90.00</string>
<string name="s4_name">Santosh</string>
<string name="s4_dept">COMP</string>
<string name="s4_city">Dhule</string>
<string name="s4_percentage">79.24</string>
<string name="s5_name">Girish</string>
<string name="s5_dept">E & TC</string>
<string name="s5_city">Dhule</string>
<string name="s5_percentage">84.00</string>
<string name="s6_name">Aachal</string>
<string name="s6_dept">MECH</string>
<string name="s6_city">Shirpur</string>
<string name="s6_percentage">69.84</string>
<string name="s7_name">Riddhi</string>
<string name="s7_dept">COMP</string>
<string name="s7_city">Shirpur</string>
<string name="s7_percentage">73.57</string>
<string name="s8_name">Dinesh</string>
<string name="s8_dept">ELEC</string>
<string name="s8_city">Nandurbar</string>
<string name="s8_percentage">80.50</string>
<string name="s9_name">Kalpesh</string>
<string name="s9_dept">CIVIL</string>
<string name="s9_city">Jalgaon</string>
<string name="s9_percentage">71.30</string>
<string name="s10_name">Harish</string>
<string name="s10_dept">COMP</string>
<string name="s10_city">Dhule</string>
<string name="s10_percentage">72.47</string>
</resources>
Xml file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/string_data_types"
android:textStyle="bold"
style="@android:style/[Link]"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:text="@string/string_int"
style="@android:style/[Link]" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="75dp"
android:text="@string/string_float"
style="@android:style/[Link]" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:text="@string/string_char"
style="@android:style/[Link]"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="125dp"
android:text="@string/string_double"
style="@android:style/[Link]"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="150dp"
android:text="@string/string_void"
style="@android:style/[Link]"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="175dp"
android:text="@string/string_boolean"
style="@android:style/[Link]"/>
</FrameLayout>
java file
package [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
}
}
[Link]
<resources>
<string name="app_name">FrameLayout</string>
<string name="string_void">void</string>
<string name="string_boolean">boolean</string>
<string name="string_double">double</string>
<string name="string_char">char</string>
<string name="string_float">float</string>
<string name="string_int">int</string>
<string name="string_data_types">Data types in Object-Oriented
Programming</string>
</resources>
Xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical"
tools:context=".MainActivity"
android:padding="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter Username"
style="@android:style/[Link]"/>
<EditText
android:id="@+id/etUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text"
style="@android:style/[Link]" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter Password"
android:layout_marginTop="10dp"
style="@android:style/[Link]" />
<EditText
android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword"
style="@android:style/[Link]" />
<Button android:id="@+id/btnLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:layout_gravity="right"
android:layout_marginTop="20dp"
style="@android:style/[Link]"/>
</LinearLayout>
Java file
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
etUsername = findViewById([Link]);
etPassword = findViewById([Link]);
btnLogin = findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) {
Xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:padding="10dp"
android:gravity="center">
<TextView android:id="@+id/tvInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Personal Information of Student"
android:textSize="20sp"
android:gravity="center_horizontal"
android:textStyle="bold"
android:layout_marginTop="20dp"
android:textColor="@android:color/holo_red_light"/>
<EditText android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter you name"
android:ems="10"
android:inputType="textPersonName"
android:textSize="18sp"
android:layout_marginTop="50dp"
android:layout_below="@+id/tvInfo"/>
<EditText android:id="@+id/dob"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Date of Birth"
android:ems="10"
android:inputType="date"
android:textSize="18sp"
android:layout_below="@+id/name"
android:layout_marginTop="25dp"/>
<EditText android:id="@+id/city"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter your City"
android:ems="10"
android:inputType="textCapCharacters"
android:textSize="18sp"
android:layout_below="@+id/dob"
android:layout_marginTop="25dp"/>
<EditText android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Email ID"
android:ems="10"
android:inputType="textEmailAddress"
android:textSize="18sp"
android:layout_below="@+id/city"
android:layout_marginTop="25dp"/>
<EditText android:id="@+id/contact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Contact number"
android:ems="10"
android:inputType="date"
android:textSize="18sp"
android:layout_below="@+id/email"
android:layout_marginTop="25dp"/>
<Button android:id="@+id/btnSubmit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/contact"
android:layout_marginTop="50dp"
android:text="Submit"
android:textSize="18sp"
android:onClick="displayData"/>
</RelativeLayout>
Java file
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
name = findViewById([Link]);
dob = findViewById([Link]);
city = findViewById([Link]);
email = findViewById([Link]);
contact = findViewById([Link]);
submit = findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) {
String n = [Link]().toString();
String d = [Link]().toString();
String ci = [Link]().toString();
String e = [Link]().toString();
String c = [Link]().toString();
Xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:padding="20dp">
<TextView android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Showing AutoCompleteTextView for Serach Engine"
android:gravity="center"
android:layout_marginTop="50dp"
android:textSize="20sp"/>
<AutoCompleteTextView android:id="@+id/auto_complete"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="20sp"
android:hint="Enter here"
android:layout_below="@id/textView"
android:layout_marginTop="30dp"/>
</RelativeLayout>
Java file
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
autotextview = findViewById([Link].auto_complete);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
[Link].simple_list_item_1, search_engines);
[Link](1);
[Link](adapter);
}
}
Xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:padding="20dp">
<TextView android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Showing AutoCompleteTextView for \nSIXTH SEMESTER
SUBJECTS"
android:gravity="center"
android:layout_marginTop="50dp"
android:textSize="20sp"/>
<AutoCompleteTextView android:id="@+id/auto_complete"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="20sp"
android:hint="Enter subject here"
android:layout_below="@+id/textView"
android:layout_marginTop="30dp"/>
</RelativeLayout>
Java file
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
AutoCompleteTextView autotextview;
String search_engines[] = {"Management", "Programming with Python",
"Mobile Application Development",
"Emerging Trends in Computer & IT", "Web
Based Application Development Using PHP",
"Entrepreneurship Development", "Capstone
Project"};
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
autotextview = findViewById([Link].auto_complete);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
[Link].simple_list_item_1, search_engines);
[Link](2);
[Link](adapter);
}
}
Xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:padding="20dp">
<ToggleButton
android:id="@+id/toggleButton"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="ToggleButton"
android:textOn="ON"
android:textOff="OFF"
android:textSize="20sp"
android:layout_centerInParent="true"/>
<TextView android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toggleButton"
android:text="Bluetooth is OFF"
android:gravity="center_horizontal"
android:layout_marginTop="20dp"
android:textSize="20sp"
android:textColor="@color/colorAccent"/>
</RelativeLayout>
Java file
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
ToggleButton toggleButton;
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
toggleButton = findViewById([Link]);
textView = findViewById([Link]);
[Link](new
[Link]() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if(isChecked)
{
[Link]("Bluetooth is " +
[Link]());
}
else
{
[Link]("Bluetooth is " +
[Link]());
}
}
});
}
}
Xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:gravity="center"
tools:context=".MainActivity">
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="First Number"
android:gravity="center"
style="@android:style/[Link]"/>
<EditText android:id="@+id/etNum1"
android:layout_width="200dp"
android:layout_height="50dp"
android:ems="10"
android:hint="Enter number 1"
android:layout_marginLeft="30dp"
android:layout_toRightOf="@id/tv1"/>
<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="Second Number"
android:gravity="center"
android:layout_below="@id/tv1"
style="@android:style/[Link]"/>
<EditText android:id="@+id/etNum2"
android:layout_width="200dp"
android:layout_height="50dp"
android:ems="10"
android:hint="Enter number 2"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@id/tv2"
android:layout_below="@id/etNum1"/>
<Button android:id="@+id/btnPlus"
android:layout_width="70dp"
android:layout_height="70dp"
android:text="+"
android:textSize="26sp"
android:layout_below="@id/tv2"
android:layout_marginTop="30dp"
android:layout_marginLeft="50dp"
android:onClick="add"/>
<Button android:id="@+id/btnMinus"
android:layout_width="70dp"
android:layout_height="70dp"
android:text="-"
android:textSize="26sp"
android:layout_below="@id/tv2"
android:layout_toRightOf="@id/btnPlus"
android:layout_marginTop="30dp"
android:onClick="subtract"/>
<Button android:id="@+id/btnMul"
android:layout_width="70dp"
android:layout_height="70dp"
android:text="*"
android:textSize="26sp"
android:layout_below="@id/tv2"
android:layout_toRightOf="@id/btnMinus"
android:layout_marginTop="30dp"
android:onClick="multiply"/>
<Button android:id="@+id/btnDiv"
android:layout_width="70dp"
android:layout_height="70dp"
android:text="/"
android:textSize="26sp"
android:layout_below="@id/tv2"
android:layout_toRightOf="@id/btnMul"
android:layout_marginTop="30dp"
android:onClick="divide"/>
<TextView android:id="@+id/tvResult"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/btnPlus"
android:textSize="26sp"
android:layout_marginTop="50dp"/>
</RelativeLayout>
Java file
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
etNum1 = findViewById([Link].etNum1);
etNum2 = findViewById([Link].etNum2);
btnPlus = findViewById([Link]);
btnMinus = findViewById([Link]);
btnMul = findViewById([Link]);
btnDiv = findViewById([Link]);
tvResult = findViewById([Link]);
}
double n1 = [Link]([Link]().toString());
double n2 = [Link]([Link]().toString());
double result = n1 + n2;
[Link]("Addition is: " + result);
}
double n1 = [Link]([Link]().toString());
double n2 = [Link]([Link]().toString());
double result = n1 - n2;
[Link]("Subtraction is: " + result);
}
double n1 = [Link]([Link]().toString());
double n2 = [Link]([Link]().toString());
double result = n1 * n2;
[Link]("Multiplication is: " + result);
}
double n1 = [Link]([Link]().toString());
double n2 = [Link]([Link]().toString());
double result = n1 / n2;
[Link]("Division is: " + result);
}
}
13 Develop an android application to create a login form for a social
networking site
Xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#495B8F"
android:padding="20dp"
tools:context=".MainActivity">
<TextView android:id="@+id/logo"
android:layout_width="match_parent"
android:layout_height="80dp"
android:text="F A C E B O O K"
android:gravity="center"
android:textSize="40sp"
android:textStyle="bold"
android:layout_marginTop="40dp"
android:textColor="@android:color/white"/>
<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@id/logo"
android:layout_marginTop="30dp"
android:background="@android:color/white"
android:fontFamily="monospace"
android:hint="Email or phone number"
android:padding="10dp"
android:textSize="22sp" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@id/username"
android:background="@android:color/white"
android:fontFamily="monospace"
android:hint="Password"
android:padding="10dp"
android:layout_marginTop="20dp"
android:textSize="22sp" />
<Button android:id="@+id/btnLogin"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@id/password"
android:layout_marginTop="30dp"
android:text="Log In"
android:background="#6D9ADD"
android:textColor="@android:color/white"
android:textSize="18sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Forgot Password?"
android:textColor="@android:color/white"
android:layout_below="@id/btnLogin"
android:layout_marginTop="10dp"
android:textSize="16sp"/>
</RelativeLayout>
Java file
package [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
}
}
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
tools:context=".MainActivity">
<TextView android:id="@+id/logo"
android:layout_width="match_parent"
android:layout_height="80dp"
android:text="R C P P"
android:gravity="center"
android:textSize="40sp"
android:textStyle="bold"
android:layout_marginTop="40dp"/>
<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@id/logo"
android:layout_marginTop="30dp"
android:background="@android:color/white"
android:fontFamily="monospace"
android:hint="Enrollment number"
android:padding="10dp"
android:textSize="22sp" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@id/username"
android:background="@android:color/white"
android:fontFamily="monospace"
android:hint="Password"
android:padding="10dp"
android:layout_marginTop="20dp"
android:textSize="22sp" />
<Button android:id="@+id/btnLogin"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@id/password"
android:layout_marginTop="30dp"
android:text="Log In"
android:background="#6D9ADD"
android:textColor="@android:color/white"
android:textSize="18sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Forgot Password?"
android:layout_below="@id/btnLogin"
android:layout_marginTop="10dp"
android:textSize="16sp"/>
</RelativeLayout>
Java file
package [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
}
}
Xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="20dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/msg"
style="@style/[Link]"
android:layout_margin="10dp"
android:textStyle="bold"/>
<CheckBox
android:id="@+id/chkAndroid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/android"
style="@style/[Link]"/>
<CheckBox
android:id="@+id/chkJava"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/java"
style="@style/[Link]"/>
<CheckBox
android:id="@+id/chkPhp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/php"
style="@style/[Link]"/>
<CheckBox
android:id="@+id/chkCpp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cpp"
style="@style/[Link]"/>
<CheckBox
android:id="@+id/chkC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/c"
style="@style/[Link]"/>
<Button android:id="@+id/btnDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Display"
android:layout_marginTop="20dp"
android:onClick="showSelected"/>
</LinearLayout>
Java file
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
public void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
chkAndroid = findViewById([Link]);
chkJava = findViewById([Link]);
chkPhp = findViewById([Link]);
chkCpp = findViewById([Link]);
chkC = findViewById([Link]);
}
if([Link]())
selected += "Android";
if([Link]())
selected += "\nJava";
if([Link]())
selected += "\nPHP";
if([Link]())
selected += "\nCPP";
if([Link]())
selected += "\nC";
[Link]
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">CheckBoxApp</string>
<string name="msg">Select your favourite programming languages</string>
<string name="android">Android</string>
<string name="java">Java</string>
<string name="php">PHP</string>
<string name="cpp">CPP</string>
<string name="c">C</string>
</resources>
Xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Single Radio Button"
android:textSize="20sp" />
<RadioButton
android:id="@+id/radio1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Radio Button 1"
android:textSize="18dp"
android:textStyle="bold"/>
<RadioButton
android:id="@+id/radio2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Radio Button 2"
android:textSize="18dp"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@android:color/black"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"/>
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Radio button inside RadioGroup"
android:textSize="20sp" />
<RadioGroup android:id="@+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radioMale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:textSize="18dp"
android:textStyle="bold" />
<RadioButton
android:id="@+id/radioFemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"
android:textSize="18dp"
android:textStyle="bold" />
</RadioGroup>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Show Selected"
android:onClick="showSelected"/>
</LinearLayout>
Java file
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
radio1 = findViewById([Link].radio1);
radio2 = findViewById([Link].radio2);
radioMale = findViewById([Link]);
radioFemale = findViewById([Link]);
radioGroup = findViewById([Link]);
}
if([Link]())
selected += "Radio Button 1\n";
if([Link]())
selected += "Radio Button 2\n";
RadioButton selectedRadio =
findViewById([Link]());
selected += [Link]().toString();
[Link]([Link], selected,
Toast.LENGTH_SHORT).show();
}
}
17 Develop an android application to display horizontal and circular
progress bar
Xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="23dp"
android:layout_marginTop="20dp"
android:indeterminate="false"
android:max="100"
android:minHeight="50dp"
android:minWidth="200dp"
android:progress="1" />
<ProgressBar
android:id="@+id/progressBar_cyclic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="50dp"
android:minWidth="50dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/progressBar"
android:layout_below="@+id/progressBar"/>
</RelativeLayout>
Java file
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
progressStatus += 1;
[Link](new Runnable() {
[Link](progressStatus);
[Link](progressStatus+"/"+[Link]());
}
});
try {
[Link](200);
}
catch (InterruptedException e) {
[Link]();
}
}
}
}).start();
}
}
Xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ListView android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
Java file
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
listView = findViewById([Link].list_view);
[Link](new
[Link]() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int
position, long id) {
[Link]([Link],
((TextView)view).getText().toString(), Toast.LENGTH_SHORT).show();
}
});
}
}
Xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="144dp"
android:layout_marginTop="68dp"
android:text="Pizza"/>
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="144dp"
android:layout_marginTop="28dp"
android:text="Coffee" />
<CheckBox
android:id="@+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="144dp"
android:layout_marginTop="28dp"
android:text="Burger"/>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="144dp"
android:layout_marginTop="184dp"
android:text="Order" />
</LinearLayout>
Java file
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
CheckBox pizza,coffe,burger;
Button buttonOrder;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
pizza=(CheckBox)findViewById([Link]);
coffe=(CheckBox)findViewById([Link].checkBox2);
burger=(CheckBox)findViewById([Link].checkBox3);
buttonOrder=(Button)findViewById([Link]);
[Link](new [Link](){
@Override
public void onClick(View view) {
int totalamount = 0;
StringBuilder result = new StringBuilder();
[Link]("Selected Items:");
if([Link]()){
[Link]("\nPizza 100Rs");
totalamount += 100;
}
if([Link]()){
[Link]("\nCoffe 50Rs");
totalamount += 50;
}
if([Link]()){
[Link]("\nBurger 120Rs");
totalamount += 120;
}
[Link]("\nTotal: "+totalamount+"Rs");
[Link](getApplicationContext(), [Link](),
Toast.LENGTH_LONG).show();
}
});
}
}
Xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:padding="20dp">
<EditText android:id="@+id/etDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="100dp"/>
<Button android:id="@+id/btnDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select Date"
android:layout_toRightOf="@+id/etDate"
android:layout_marginTop="100dp"
android:onClick="showDatePicker"/>
<EditText android:id="@+id/etTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_below="@+id/etDate"/>
<Button android:id="@+id/btnTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select Time"
android:layout_toRightOf="@+id/etTime"
android:layout_below="@+id/btnDate"
android:onClick="showTimePicker"/>
</RelativeLayout>
Java file
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
etDate = findViewById([Link]);
etTime = findViewById([Link]);
btnDate = findViewById([Link]);
btnTime = findViewById([Link]);
}
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int
minute) {
[Link](hourOfDay + " : " + minute);
}
}, mHour,mMinute, false);
[Link]();
}
}
Xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>
Java file
package [Link];
import [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
Log.d("MainActivity", "onCreate() called");
}
@Override
protected void onStart() {
[Link]();
Log.d("MainActivity", "onStart() called");
}
@Override
protected void onResume() {
[Link]();
Log.d("MainActivity", "onResume() called");
}
@Override
protected void onRestart() {
[Link]();
Log.d("MainActivity", "onRestart() called");
}
@Override
protected void onPause() {
[Link]();
Log.d("MainActivity", "onPause() called");
}
@Override
protected void onStop() {
[Link]();
Log.d("MainActivity", "onStop() called");
}
@Override
protected void onDestroy() {
[Link]();
Log.d("MainActivity", "onDestroy() called");
}
}
22 Develop an android application to calculate Factorial of a number
using Activity Intents
Xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:padding="20dp">
<EditText android:id="@+id/etNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter the number"
android:inputType="number"
android:layout_marginTop="50dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Factorial"
android:onClick="displayFactorial"/>
</LinearLayout>
Java file
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
EditText etNumber;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
etNumber = findViewById([Link]);
}
activity_factorial.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FactorialActivity"
android:padding="20dp">
<TextView android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Factorial of number is"
style="@style/[Link]"/>
</RelativeLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_factorial);
Bundle b = getIntent().getExtras();
int no = [Link]([Link]("number"));
long f=1;
tv = findViewById([Link]);
[Link]("Factorial of " + no + " is " + f);
}
}
Xml file
[Link]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="[Link]
package="[Link]">
<uses-permission android:name="[Link].RECEIVE_BOOT_COMPLETED"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="[Link]" />
<category android:name="[Link]" />
</intent-filter>
</activity>
<receiver android:name=".MyBroadcastReceiver">
<intent-filter>
<action android:name="[Link].BOOT_COMPLETED"/>
<action android:name="[Link].CONNECTIVITY_CHANGE"/>
</intent-filter>
</receiver>
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>
Java file
package [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
public void onReceive(Context context, Intent intent) {
if(Intent.ACTION_BOOT_COMPLETED.equals([Link]())) {
[Link](context, "Boot Completed", Toast.LENGTH_SHORT).show();
}
if(ConnectivityManager.CONNECTIVITY_ACTION.equals([Link]())) {
[Link](context, "Connectivity Changed",
Toast.LENGTH_SHORT).show();
}
}
}
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="[Link]" />
<category android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:padding="10dp">
<TextView android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</ScrollView>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
tv = findViewById([Link]);
String sensorInfo = "";
for(Sensor s : sensorList) {
sensorInfo += [Link]() + "\n";
}
[Link](sensorInfo);
}
}
[Link]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="[Link]
package="[Link]">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="[Link]" />
<category android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:padding="20dp">
<ImageView android:id="@+id/imageView"
android:layout_width="300dp"
android:layout_height="300dp"
android:text="Hello World!"
android:background="@drawable/border_image_view"
android:layout_gravity="center_horizontal"/>
<Button android:id="@+id/btnCapture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Capture"
android:layout_marginTop="20dp"
android:onClick="captureImage"/>
</LinearLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
imageView = findViewById([Link]);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == REQUEST_CODE_CAMERA) {
if(resultCode == RESULT_OK) {
Bitmap bitmap = (Bitmap) [Link]().get("data");
[Link](bitmap);
}
else {
[Link](getApplicationContext(), "Cancelled by user",
Toast.LENGTH_SHORT).show();
}
}
[Link](requestCode, resultCode, data);
}
}
[Link]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="[Link]
package="[Link]">
<uses-permission android:name="[Link]"/>
<uses-permission android:name="[Link].BLUETOOTH_ADMIN"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="[Link]" />
<category android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:padding="20dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bluetooth"
android:textSize="20sp"
android:textStyle="bold"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Turn On"
android:onClick="turnOn"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get Visible"
android:onClick="getVisible"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="List Devices"
android:onClick="listDevices"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Turn Off"
android:onClick="turnOff"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Paired Devices"
android:textColor="@android:color/holo_red_dark"/>
<ListView android:id="@+id/listView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
ba = [Link]();
listView = findViewById([Link]);
}
if(![Link]()) {
Intent intentOn = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(intentOn, 0);
[Link](getApplicationContext(), "Turned ON",
Toast.LENGTH_SHORT).show();
}
else {
[Link](getApplicationContext(), "Already ON",
Toast.LENGTH_SHORT).show();
}
}
for(BluetoothDevice b : pairedDevices) {
[Link]([Link]());
}
ArrayAdapter adapter = new ArrayAdapter(getApplicationContext(),
[Link].simple_list_item_1, list);
[Link](adapter);
}
}
[Link]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="[Link]
package="[Link]">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="[Link]" />
<category android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:padding="20dp"
android:orientation="vertical">
<EditText android:id="@+id/etRN"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter roll no" />
<EditText android:id="@+id/etName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter name" />
<Button android:id="@+id/btnAddStudent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add Student"
android:onClick="addNewStudent"/>
<TextView android:id="@+id/tvInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22sp"
android:padding="10dp"/>
</LinearLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
DatabaseHelper databaseHelper;
EditText etRN, etName;
TextView tvInfo;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
etRN = findViewById([Link]);
etName = findViewById([Link]);
tvInfo = findViewById([Link]);
databaseHelper = new DatabaseHelper([Link]);
}
public void addNewStudent(View view) {
int rn = [Link]([Link]().toString());
String name = [Link]().toString();
[Link](rn, name);
displayAllStudents();
}
for(Student s : studentList) {
data += [Link]() + ", " + [Link]() + "\n";
}
[Link](data);
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
public void onCreate(SQLiteDatabase db) {
String query = "CREATE TABLE " + TABLE_NAME + "( " + COLUMN_ID + " INTEGER
PRIMARY KEY AUTOINCREMENT, " + COLUMN_ROLL_NO + " TEXT"+", " + COLUMN_NAME + ");";
try {
[Link](query);
}
catch(Exception e) {
[Link]();
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
[Link]("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
while ([Link]()) {
rn = [Link]([Link](COLUMN_ROLL_NO));
n = [Link]([Link](COLUMN_NAME));
[Link](new Student(rn, n));
}
[Link]();
return list;
}
SQLiteDatabase db = getWritableDatabase();
[Link]("DELETE FROM " + TABLE_NAME + " WHERE " + COLUMN_ROLL_NO + "=" +
rollno);
}
}
[Link]
package [Link];
public class Student {
int rollno;
String name;
public Student(int rollno, String name) {
[Link] = rollno;
[Link] = name;
}
[Link]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="[Link]
package="[Link]">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="[Link]" />
<category android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:padding="20dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login Form"
android:layout_marginTop="100dp"
android:textSize="35sp"
android:textColor="@color/colorAccent"
android:gravity="center_horizontal"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Username"
android:layout_marginTop="100dp"
android:textSize="20sp"/>
<EditText android:id="@+id/etUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Password"
android:textSize="20sp"/>
<EditText android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"/>
<TextView android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/holo_red_dark"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:layout_gravity="center_horizontal"
android:layout_marginTop="50dp"
android:onClick="login"/>
</LinearLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
EditText etUsername,etPassword;
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
etUsername = findViewById([Link]);
etPassword = findViewById([Link]);
tv = findViewById([Link]);
}
if([Link]().toString().equals("admin") &&
[Link]().toString().equals("1234")) {
[Link]("Login Successful");
}
else {
[Link]("");
[Link]([Link], "Login fail.",
Toast.LENGTH_SHORT).show();
}
}
}
[Link]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="[Link]
package="[Link]">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="[Link]" />
<category android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:padding="20dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login Form"
android:layout_marginTop="100dp"
android:textSize="35sp"
android:textColor="@color/colorAccent"
android:gravity="center_horizontal"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Username"
android:layout_marginTop="100dp"
android:textSize="20sp"/>
<EditText android:id="@+id/etUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:textSize="20sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Password"
android:textSize="20sp"/>
<EditText android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:textSize="20sp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:layout_gravity="center_horizontal"
android:layout_marginTop="50dp"
android:onClick="login" />
</LinearLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
EditText etUsername,etPassword;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
etUsername = findViewById([Link]);
etPassword = findViewById([Link]);
}
if([Link]("") || [Link]("")) {
return "Plz enter both username and password";
}