Switching between activities in android?

前端 未结 7 578
有刺的猬
有刺的猬 2020-12-18 10:22

In my android application, I have following requirement.

Activity A --> Activity B(Go to A Option) --> Activity C(Go To A Option,Go To B Option)

<
7条回答
  •  生来不讨喜
    2020-12-18 10:58

    You can do this as:

    On back press option:

    1. onBackPressed(){ @Override public void onBackPressed() {

      // TODO Auto-generated method stub
          super.onBackPressed();
      //Your method intent
          Intent intent = new Intent(A.this, C.class);
          startActivity(intent);
      

      }

    Using a button:

    1. button.setOnClickListener( new View.OnClickListener() {

           public void onClick(View v)
      
           {
      
                   Intent intent = new Intent(A.this, C.class);
               startActivity(intent);
            // finish(); // may use finish if do not want endless loop
      }});
      

提交回复
热议问题