Documente Academic
Documente Profesional
Documente Cultură
To be filled by Student
Q.No.1 (Marks 1)
Write a code to create a toast which displays “Mid Term paper is very easy” by clicking anywhere on
the screen. (Only write specific code, not system generated)
aTextView.setText(text_One);
bTextView.setText(text_Two); }});
buttonToSwap.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
first_Text = textViewA.getText().toString();
sec_Text = textViewB.getText().toString();
textViewA.setText(sec_Text);
textViewB.setText(first_Text); }});
What is the difference between adapter and adapterView? Give two examples of an adapterView.
(Write specific code only, expand space if require)
Q.No.5. (Marks 4)
There are three activities named First.java, Second.java and Third.java. Move a string value
as country code from first activity to second activity. e.g. 0092. Now, On second activity
append country code and operator code. For example, 0092321. Then send this value to
third activity. On third activity, append a seven digit number with this value. e.g.
00923212342345. And now show this resultant string in third activity in the form of toast
(Write Specific code, Expand Space if require)
Answer: Button shiftToSecButton = findViewById(R.id.shiftToSecButton);
shiftToSecButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String countryCode = "0900";
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
intent.putExtra("countryCode", countryCode);
startActivity(intent); }});
Q.No.6. (Marks 1)
Discuss all the four states of an android activity and draw activity life cycle by hand and
include picture in answer.
Answer:
}}