How to have activity in Android with a close button at the top corner?

后端 未结 4 1322
长发绾君心
长发绾君心 2020-12-08 23:43

I would like to have an activity which would consist of a close button i.e \'x\' at the right top corner closing the activity. Any examples on this will be very much helpful

4条回答
  •  臣服心动
    2020-12-09 00:02

    In your xml add one button view

    syntax:

    and inside your activity or java class

    syntax:

    public void closeActivity(View v){
    
     Intent intent=new Intent(currentclass.this,statingclass.class);
     startActivity(intent);
     finish();
    

提交回复
热议问题