我知道之前有人问过这个关于导航的问题,但是 Developer Docs说
As another mode of navigation (or filtering)
那么,操作栏中仅重新查询数据库并根据所选选项更新 View 的微调器的替代品是什么?
最佳答案
这个问题已经很老了,但我还是给出了答案。
当您迁移到 v7 支持库时需要更改监听器。
public class YourActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener
关于 Spinner 的创建
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(this); //set the listener
实现监听方法
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Snackbar.make(this.getCurrentFocus(), "OnItemSelected", Snackbar.LENGTH_LONG);
//Your implementation here
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
Snackbar.make(this.getCurrentFocus(), "onNothingSelected", Snackbar.LENGTH_LONG);
//Your implementation here
}
用到的onNothingSelected方法不清楚。你可以阅读this发帖澄清。
希望对你有帮助。
问候
关于android - ActionBar.OnNavigationListener 弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27672192/