我在logcat中遇到了这个错误
03-11 15:09:43.403 2317-2317/com.manning.aip.mymovies W/View﹕ requestLayout() improperly called by android.widget.CheckedTextView{238af57c V.ED.... ......ID 0,0-540,96 #1020014 android:id/text1} during layout: running second layout pass
我的应用从资源加载StringArray并在ListView中显示
这是我的活动类,它扩展了ListActivity
public class MyMovies extends ListActivity {
private MovieAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ListView listView = getListView();
Button backToTop =
(Button) getLayoutInflater().inflate(R.layout.list_footer, listView, false);
backToTop.setCompoundDrawablesWithIntrinsicBounds(getResources()
.getDrawable(android.R.drawable.ic_menu_upload), null, null,
null);
listView.addFooterView(backToTop, null, true);
this.adapter = new MovieAdapter(this);
listView.setAdapter(this.adapter);
listView.setItemsCanFocus(false);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
this.adapter.toggleMovie(position);
this.adapter.notifyDataSetChanged();
}
public void backToTop(View view) {
getListView().setSelection(0);
}
}
这是我使用
的适配器public class MovieAdapter extends ArrayAdapter<String> {
// private HashMap<Integer, Boolean> movieCollection =
// new HashMap<Integer, Boolean>();
// more memory efficient way of doing things
private SparseBooleanArray movieCollection =
new SparseBooleanArray();
public MovieAdapter(Context context) {
super(context, R.layout.movie_item, android.R.id.text1, context
.getResources().getStringArray(R.array.movies));
}
public void toggleMovie(int position) {
if (!isInCollection(position)) {
movieCollection.put(position, true);
} else {
movieCollection.put(position, false);
}
}
public boolean isInCollection(int position) {
return movieCollection.get(position) == Boolean.TRUE;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View listItem = super.getView(position, convertView, parent);
CheckedTextView checkMark;
ViewHolder holder = (ViewHolder) listItem.getTag();
if (holder != null) {
checkMark = holder.checkMark;
} else {
checkMark = (CheckedTextView) listItem.findViewById(android.R.id.text1);
holder = new ViewHolder(checkMark);
listItem.setTag(holder);
}
checkMark.setChecked(isInCollection(position));
return listItem;
}
private class ViewHolder {
protected final CheckedTextView checkMark;
public ViewHolder(CheckedTextView checkMark) {
this.checkMark = checkMark;
}
}
}
请帮我解决这个问题。