MAD Manual
MAD Manual
MAD Manual
X. Exercise.
Xml file:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Java file:
package com.example.manual;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Output-
xml file:
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:layout_marginTop="190dp"
android:layout_marginLeft="100dp"
/>
<TextView
android:id="@+id/marks"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text=""
android:layout_marginLeft="100dp"
android:layout_marginTop="220dp"
/>
</RelativeLayout>
Java file:
package com.example.manual;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
1. Write a program to place Name, Age and mobile number linearly (Vertical) on the display screen using Linear
layout.
Xml file:
Java File:
package com.example.manual;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
TextView name,mark,number;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
name = (TextView) findViewById(R.id.name);
mark = (TextView) findViewById(R.id.marks);
number = (TextView) findViewById(R.id.number);
name.setText("Name.");
mark.setText("Age.");
number.setText("Mobile Number.");
}
Output:-
2. Write a program to place Name, Age and mobile number centrally on the display screen using Absolute
layout.
Xml file:
Java file:
package com.example.manual;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
TextView name,mark,number;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
name = (TextView) findViewById(R.id.name);
mark = (TextView) findViewById(R.id.marks);
number = (TextView) findViewById(R.id.number);
name.setText("Name.");
mark.setText("Age.");
number.setText("Mobile Number.");
}
Output:-
Page no 29
Practical No. 6: Develop a program to implement frame layout, table
layout and relative layout.
X. Exercise.
1. Write a program to display 10 students basic information in a table form using Table layout.
Code:-
Xml file:-
android:layout_height="wrap_content"
android:text="10"
android:textAlignment="center"
android:layout_weight="0.1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Malhar Kulkarni"
android:textAlignment="center"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="19"
android:textAlignment="center"
android:layout_weight="0.2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gadhinglaj"
android:textAlignment="center"
android:layout_weight="1" />
</TableRow>
</TableLayout>
Java File:-
package com.example.autocompletetext;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Output:-
2. Write a program to display all the data types in object-oriented programming using Frame layout.
Code:-
Xml file:-
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="40dp"
android:id="@+id/frameLayout">
<TextView
android:id="@+id/intTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="25dp"/>
<TextView
android:id="@+id/floatTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="40dp"/>
<TextView
android:id="@+id/doubleTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="55dp"/>
<TextView
android:id="@+id/booleanTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="70dp"/>
<TextView
android:id="@+id/stringTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="85dp"/>
<TextView
android:id="@+id/charTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="100dp"/>
</FrameLayout>
Java file:-
package com.example.autocompletetext;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
FrameLayout frameLayout;
TextView textView1,textView2,textView3,textView4,textView5,textView6;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
frameLayout = findViewById(R.id.frameLayout);
textView1 = findViewById(R.id.intTextView);
textView2 = findViewById(R.id.floatTextView);
textView3 = findViewById(R.id.stringTextView);
textView4 = findViewById(R.id.booleanTextView);
textView5 = findViewById(R.id.doubleTextView);
textView6 = findViewById(R.id.charTextView);
textView1.setText(datatype[0]+": "+datatypeDesc[0]);
textView2.setText(datatype[1]+": "+datatypeDesc[1]);
textView3.setText(datatype[2]+": "+datatypeDesc[2]);
textView4.setText(datatype[3]+": "+datatypeDesc[3]);
textView5.setText(datatype[4]+": "+datatypeDesc[4]);
textView6.setText(datatype[5]+": "+datatypeDesc[5]);
}
}
Output:-
Practical No. 7: Develop a program to implement Text View and Edit Text.
X. Exercise.
1. Write a program to accept username and password from the end user using Text
View and Edit Text.
Xml file:
<TextView
android:layout_marginTop="150dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:text="Username"
/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginLeft="100dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:text="Password"
/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginLeft="100dp"
android:inputType="textPassword"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:text="Login"
/>
</LinearLayout>
Output:
Xml code:
<EditText
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Name"
android:layout_marginTop="100dp"
android:layout_marginLeft="10dp"
/>
<EditText
android:id="@+id/sname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Surname"
android:layout_marginLeft="10dp"
android:inputType="textPersonName"
/>
<EditText
android:id="@+id/mobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Mobile"
android:layout_marginLeft="10dp"
android:inputType="number"
/>
<EditText
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Email"
android:layout_marginLeft="10dp"
android:inputType="textEmailAddress"
/>
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Submit"
/>
<TextView
android:id="@+id/result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:textSize="18dp"
/>
</LinearLayout>
Java code:
package com.example.login;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
Output: