AlertDialog.Builder的参考页面列出了API 11+的getContext()方法,但此代码:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater inflater = LayoutInflater.from(builder.getContext());
}
将在Eclipse中显示错误:
The method getContext() is undefined for the type AlertDialog.Builder
但我使用的是API级别15,所以我认为它可用。任何人都可以看到问题所在吗?