Posts

Showing posts from July, 2022

Question Answer In Android Studio

  package com.example.ch4practiceset ; import androidx.appcompat.app.AppCompatActivity ; import android.os.Bundle ; import android.view.View ; import android.widget.Button ; import android.widget.TextView ; import android.widget.Toast ; public class MainActivity extends AppCompatActivity { private String [] questions = { "Java is a person?" , "Java is introduced in 1233? " , "java is created with Python?" , "Java has a Abstact classes" , "Java Supporte interface?" }; private boolean [] answers = { false , false , false , true , true }; private int score = 0 ; Button yes ; Button no ; TextView question ; private int index = 0 ; @Override protected void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ); setContentView ( R . layout . activity_main ); yes = findViewById ( R . id . yes ); no = findViewById ( R . id . no ); question = fi

Android use of the one page to another page transfer with use of Intent

package com.example.firstmultiscreen ; import androidx.appcompat.app.AppCompatActivity ; import android.content.Intent ; import android.os.Bundle ; import android.view.View ; import android.widget.EditText ; import android.widget.Toast ; public class MainActivity extends AppCompatActivity { EditText editText ; public static final String EXTRA_NAME = "com.example.firstmultiscreen.extra.NAME" ; @Override protected void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ); setContentView ( R . layout . activity_main ); } public void openActivity ( View v ){ Toast . makeText ( this , "Openning Second Activity" , Toast . LENGTH_SHORT ). show (); Intent intent = new Intent ( this , MainActivity2 . class ); editText = findViewById ( R . id . name ); String nameTest = editText . getText (). toString (); intent . putExtra ( EXTRA_NAME , nameTest ); startActivit

Unit Converter in Android Studio (JAVA)

package com.example.unconvert ; import android.support.v7.app.AppCompatActivity ; import android.os.Bundle ; import android.view.View ; import android.widget.Button ; import android.widget.EditText ; import android.widget.TextView ; import android.widget.Toast ; public class MainActivity extends AppCompatActivity { private Button button ; private TextView textView2 ; private EditText editText ; @Override protected void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ); setContentView ( R . layout . activity_main ); button = findViewById ( R . id . button ); textView2 = findViewById ( R . id . textView2 ); editText = findViewById ( R . id . edit2 ); button . setOnClickListener ( new View . OnClickListener () { @Override public void onClick ( View v ) { Toast . makeText ( MainActivity . this , "Hi clicked Listner worked" , Toast . LENGTH_SHO

Two number sum in Android Studio (JAVA)

  package com.example.twonumbercalculate ; import android.support.v7.app.AppCompatActivity ; import android.os.Bundle ; import android.view.View ; import android.widget.Button ; import android.widget.EditText ; import android.widget.TextView ; import android.widget.Toast ; public class MainActivity extends AppCompatActivity { EditText n1 , n2 ; TextView textView ; Button button2 ; @Override protected void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ); setContentView ( R . layout . activity_main ); textView = findViewById ( R . id . textView ); button2 = findViewById ( R . id . button2 ); n1 = findViewById ( R . id . n1 ); n2 = findViewById ( R . id . n2 ); button2 . setOnClickListener ( new View . OnClickListener () { @Override public void onClick ( View v ) { int sum = Integer . parseInt ( n1 . getText (). toString ()) + Integer . parse

Multipliction table app in Android Studio (JAVA)

package com.example.multiplicationtable ; 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 ; public class MainActivity extends AppCompatActivity { TextView textView ; EditText num ; Button button ; String result ; @Override protected void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ); setContentView ( R . layout . activity_main ); textView = findViewById ( R . id . textView ); num = findViewById ( R . id . num ); button = findViewById ( R . id . button ); button . setOnClickListener ( new View . OnClickListener () { @Override public void onClick ( View v ) { int sum = Integer . parseInt ( num . getText (). toString ()); result = " " ; for ( int i