android - Activity中的Menu怎么才能使用SnackBar(不知道怎么获取view)?
巴扎黑
巴扎黑 2017-04-17 17:05:18
0
1
900
巴扎黑
巴扎黑

reply all(1)
大家讲道理

Just use the Layout where the container is located as the view, for example:

public class SnackbarTestActivity extends Activity {

CoordinatorLayout container;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_snackbar_test);
    container = (CoordinatorLayout) findViewById(R.id.container);
}

public void createSnackbar(View v) {
    Snackbar.make(container, "SnackbarTest", Snackbar.LENGTH_LONG).show();
}
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template