我有一个Fragment类,它有 -
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.my_list, container, false);
// Set the adapter
mAdapter = new MyAdapter(getActivity(), null, 0);
mListView = (AbsListView) view.findViewById(android.R.id.list);
mListView.setEmptyView(emptyView);
mListView.setAdapter(mAdapter);
// Set OnItemClickListener so we can be notified on item clicks
mListView.setOnItemClickListener(this);
return view;
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
//Save TextView attributes here
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
//Restore them here
}
}
我有MyAdapter
类,其中包含TextView 'time'
-
@Override
public void bindView(View view, Context context, Cursor cursor) {
ViewHolder viewHolder = (ViewHolder) view.getTag();
Child child = children.createStopFromCursor(cursor);
viewHolder.time.setText(strText);
viewHolder.time.setTextColor(0xff000000);
viewHolder.time.setTextSize(17);
viewHolder.time.setVisibility(View.VISIBLE);
viewHolder.time.setBackgroundColor(nColor);
viewHolder.time.setPadding(25,25,25,25);
view.invalidate();
}
}
我的问题是我想在time
中保存textview onSaveInstanceState()
的各种属性,例如文字,颜色,填充等,这样当我的手机配置发生变化时,我就可以使用它{{1} }。我如何实现这一目标?