我有一个方法,initializeViews
它在最后一行遇到ArrayAdapter constructor undefined
错误。
该方法位于F1Fragment
,其中扩展MainFragment
。MainFragment
然后附加到一个Activity
.
我们不能Fragment
在ArrayAdapter<string>
构造函数中给出 a 的上下文吗?我是安卓新手。请纠正我。提前致谢。
private void initializeViews(RelativeLayout contentLayout) {
leaguesListView = ( ListView ) contentLayout.findViewById ( R.id.leaguesListView );
progressLinear = (LinearLayout) contentLayout.findViewById ( R.id.progressLeagues );
values= new String[] { "RedBullRacing", "McLaren", "Lotus",
"ForceIndia", "HRT", "Ferrari" };
adapter= new ArrayAdapter<String>(F1Fragment.this, android.R.layout.simple_list_item_1, android.R.id.text1, values);
}