Уже делал, в одних проектах работает, а здесь не хочет, что не так?
Функция onResume вызывается, но обновления не происходит.
Спасибо!
Код: Выделить всё
public class FragmentTabActive extends SherlockFragment implements OnItemClickListener {
private final String LOG_TAG = "FRAGMENT_TAB_ACTIVE";
private final static String PERIOD_NAME = "periodName";
private ArrayList<HashMap<String, Object>> periodListData;
private ListView periodListView;
private ArrayList<String> periodNames;
private SimpleAdapter periodListAdapter;
@Override
public SherlockFragmentActivity getSherlockActivity() {
return super.getSherlockActivity();
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
setUserVisibleHint(true);
}
@Override
public void onResume() {
super.onResume();
periodListAdapter.notifyDataSetChanged();
periodListView.invalidateViews();
Log.i(LOG_TAG, "onResume");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.periods_list, container, false);
periodListView = (ListView) view.findViewById(R.id.periodsListView);
periodListData = new ArrayList<HashMap<String, Object>>();
periodNames = new ArrayList<String>();
fillListView();
periodListAdapter = new SimpleAdapter(getActivity(), periodListData, R.layout.period_list_row, new String[] { PERIOD_NAME },
new int[] { R.id.periodsListPeriodName });
periodListView.setAdapter(periodListAdapter);
periodListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
periodListView.setOnItemClickListener(this);
return view;
}
private HashMap<String, Object> fillListView() {
HashMap<String, Object> fillMap = null;
SQLiteDatabase db = DatabaseHelper.getInstance(getActivity()).getReadableDatabase();
Cursor cursor = db.query(true, "periods", null, null, null, null, null, null, null);
if (cursor.moveToFirst()) {
int nameColIndex = cursor.getColumnIndex("periodName");
do {
fillMap = new HashMap<String, Object>();
periodNames.add(cursor.getString(nameColIndex));
fillMap.put(PERIOD_NAME, cursor.getString(nameColIndex));
periodListData.add(fillMap);
} while (cursor.moveToNext());
cursor.close();
db.close();
} else {
Toast.makeText(getActivity(), getResources().getString(R.string.empty_list_view_message), Toast.LENGTH_LONG).show();
}
return fillMap;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String periodName = periodNames.get(position);
Intent inient = new Intent(getActivity(), PeriodActivity.class);
inient.putExtra("periodName", periodName);
getActivity().startActivity(inient);
Toast.makeText(getActivity(), periodName, Toast.LENGTH_LONG).show();
}
}