0% found this document useful (0 votes)
11 views3 pages

Android Progs

The document contains three Android application examples, each with XML layouts and corresponding Java code. The first program counts button clicks, the second changes text size and color, and the third displays a welcome message using user input. Each example demonstrates basic UI components and event handling in Android development.

Uploaded by

Lokesh Rajasekar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Android Progs

The document contains three Android application examples, each with XML layouts and corresponding Java code. The first program counts button clicks, the second changes text size and color, and the third displays a welcome message using user input. Each example demonstrates basic UI components and event handling in Android development.

Uploaded by

Lokesh Rajasekar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

3PROGRAM

XML

<LinearLayout xmlns:android="[Link]
android:orientation="vertical" android:gravity="center"
android:layout_width="match_parent" android:layout_height="match_parent">

<TextView android:id="@+id/tv" android:text="0"


android:textSize="40sp" android:layout_marginBottom="20dp"
android:layout_width="wrap_content" android:layout_height="wrap_content"/>

<Button android:id="@+id/btn" android:text="Count"


android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</LinearLayout>

JAVA

package [Link].prog3;
import [Link];
import [Link].*;
import [Link];

public class MainActivity extends AppCompatActivity {


int c=0;
@Override protected void onCreate(Bundle b) {
[Link](b);
setContentView([Link].activity_main);
TextView tv=findViewById([Link]);
findViewById([Link]).setOnClickListener(v->[Link](""+ ++c));
}
}
4 TH PROGRAM

XML

<LinearLayout xmlns:android="[Link]
android:orientation="vertical" android:gravity="center"
android:layout_width="match_parent" android:layout_height="match_parent">

<TextView android:id="@+id/tv" android:text="Hello"


android:textSize="20sp" android:textColor="#000000"
android:layout_width="wrap_content" android:layout_height="wrap_content"/>

<Button android:id="@+id/btn" android:text="Change"


android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</LinearLayout>

JAVA
package [Link];

import [Link];

import [Link].*;

import [Link];

public class MainActivity extends AppCompatActivity {

@Override protected void onCreate(Bundle b) {

[Link](b);

setContentView([Link].activity_main);

TextView tv=findViewById([Link]);

findViewById([Link]).setOnClickListener(v->{

[Link](30); // change size

[Link](0xFFFF0000); // change color (red)

});

}
5th PROG
XML

<LinearLayout xmlns:android="[Link]
android:orientation="vertical" android:gravity="center"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView android:id="@+id/tv" android:text="Give ur Name"
android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<EditText android:id="@+id/et" android:ems="10"
android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<Button android:id="@+id/btn" android:text="Submit"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:onClick="show"/>
</LinearLayout>

JAVA
package [Link];
import [Link];
import [Link];
import [Link];
import [Link].*;
public class MainActivity extends Activity {
EditText et;
@Override protected void onCreate(Bundle b) {
[Link](b);
setContentView([Link].activity_main);
et=findViewById([Link]);
}
public void show(View v){
[Link](this,"Welcome "+[Link](),Toast.LENGTH_SHORT).show();
}
}

You might also like