Standard structure
public class MainActivity extends Activity {
int count = 0; // declare variables here (outside onCreate)
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
// PUT YOUR FUNCTIONALITY CODE HERE
}
}
FUNCTIONALITY CODE OF ALL PROGRAMS
3. Counter (+1 / -1)
TextView tv = findViewById([Link]);
Button b1 = findViewById([Link]);
Button b2 = findViewById([Link].button2);
[Link](v -> {
count++;
[Link]("Count = " + count);
});
[Link](v -> {
count--;
[Link]("Count = " + count);
});
4. Change Font Size
TextView t = findViewById([Link].textView1);
Button b1 = findViewById([Link].button1);
[Link](v -> {
[Link](font);
font += 5;
if (font == 50)
font = 30;
});
4. Change Text Color
TextView t = findViewById([Link].textView1);
Button b2 = findViewById([Link].button2);
[Link](v -> {
ch++;
if (ch == 7)
ch = 1;
switch (ch) {
case 1: [Link]([Link]); break;
case 2: [Link]([Link]); break;
case 3: [Link]([Link]); break;
case 4: [Link]([Link]); break;
case 5: [Link]([Link]); break;
case 6: [Link]([Link]); break;
});
5. EditText + Toast
EditText t = findViewById([Link].et1);
[Link](this,
"Welcome " + [Link]().toString(),
Toast.LENGTH_LONG).show();