MainActivity2.java In the example of multiple activities with contacts: Is there another way to go back to the previous Activity? If there is what would it be? bb.setOnClickListener(new View.OnClickListener() { public void onClick(View view) {finish(); } }); public class MainActivity2 extends AppCompatActivity { String[] phone = {"121121","131131","141141","151151"}; int[] image={R.drawable. img1,R.drawable. img2, R. drawable.img3, R. drawable.img4}; @Override protected void onCreate (Bundle savedInstanceState) { super.onCreate (savedInstanceState); setContentView (R.layout.activity_main2); Intent intent2 = getIntent(); int i = intent2.getIntExtra ("index", 0); String name = intent2.getStringExtra ("name"); TextView tv1 = findViewById(R.id. text1); tv1.setText(name); ImageView iv = findViewById(R.id. cImage); iv.setImageResource(image[i]); TextView tv2 = findViewById(R.id. text2); tv2.setText(phone[i]); Button bb = findViewById(R.id.btn); bb.setOnClickListener(new View.OnClickListener() { public void onClick(View view) {finish(); } });}}

icon
Related questions
Question
MainActivity2.java
In the example of multiple activities with contacts:
Is there another way to go back to the previous Activity? If there is what
would it be?
bb.setOnClickListener(new View.OnClickListener()
{ public void onClick(View view)
{finish(); } });
public class MainActivity2 extends AppCompatActivity {
String[] phone = {"121121","131131","141141","151151"};
int[]
image={R.drawable. img1,R.drawable. img2, R. drawable.img3, R. drawable.img4};
@Override
protected void onCreate (Bundle savedInstanceState)
{
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main2);
Intent intent2 = getIntent();
int i = intent2.getIntExtra ("index", 0);
String name = intent2.getStringExtra ("name");
TextView tv1 = findViewById(R.id. text1);
tv1.setText(name);
ImageView iv = findViewById(R.id. cImage);
iv.setImageResource(image[i]);
TextView tv2 = findViewById(R.id. text2);
tv2.setText(phone[i]);
Button bb = findViewById(R.id.btn);
bb.setOnClickListener (new View.OnClickListener()
{ public void onClick(View view)
{finish(); } });}}
1
Transcribed Image Text:MainActivity2.java In the example of multiple activities with contacts: Is there another way to go back to the previous Activity? If there is what would it be? bb.setOnClickListener(new View.OnClickListener() { public void onClick(View view) {finish(); } }); public class MainActivity2 extends AppCompatActivity { String[] phone = {"121121","131131","141141","151151"}; int[] image={R.drawable. img1,R.drawable. img2, R. drawable.img3, R. drawable.img4}; @Override protected void onCreate (Bundle savedInstanceState) { super.onCreate (savedInstanceState); setContentView (R.layout.activity_main2); Intent intent2 = getIntent(); int i = intent2.getIntExtra ("index", 0); String name = intent2.getStringExtra ("name"); TextView tv1 = findViewById(R.id. text1); tv1.setText(name); ImageView iv = findViewById(R.id. cImage); iv.setImageResource(image[i]); TextView tv2 = findViewById(R.id. text2); tv2.setText(phone[i]); Button bb = findViewById(R.id.btn); bb.setOnClickListener (new View.OnClickListener() { public void onClick(View view) {finish(); } });}} 1
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer