How to make modification Android Snackbar containing with LayoutInflater button and editText

前端 未结 4 1132
一个人的身影
一个人的身影 2021-01-23 06:36

My project now is how to make a Snackbar displayed at the bottom of the screen. The Snackbar contain with editText and three button for selection categories. I use LayoutInflat

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-23 07:12

    Follow this documentation

    https://developer.android.com/training/snackbar/action.html

    public class MyUndoListener implements View.OnClickListener{
    
        &Override
        public void onClick(View v) {
    
            // Code to undo the user's last action
        }
    }
    

    Now for setAction()

    Snackbar mySnackbar = Snackbar.make(findViewById(R.id.myCoordinatorLayout),
                                    R.string.email_archived, Snackbar.LENGTH_SHORT);
    mySnackbar.setAction(R.string.undo_string, new MyUndoListener());
    mySnackbar.show();
    

提交回复
热议问题