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();
}
}