私はSyncAdapter
webservice を呼び出し、データベースを挿入/更新することを実装しました。このデータの一部を表示したいので、 を介してデータが表示されるようにListView
実装しました。Web から新しいデータを取得してデータベースに挿入する場合を除いて、すべて正常に動作します。更新されず、新しいデータが表示されませんListFragment
CursorAdapter
CursorAdapter
ListView
私のContentProvider
中で、私が呼び出すたびに挿入した後context.getContentResolver().notifyChange(uri, null);
これはListFragment
アダプタを実装するための部分です
mAdapter = new ObavijestiAdapter(getActivity(), null, 0);
setListAdapter(mAdapter);
これが私のカスタムアダプターです
public class ObavijestiAdapter extends CursorAdapter {
private Cursor mCursor;
private Context mContext;
private final LayoutInflater mInflater;
static class ViewHolder {
public TextView hTextNaslov;
public TextView hTextOpis;
public ImageView hImage;
}
public ObavijestiAdapter(Context context, Cursor c, int flags) {
super(context, c, flags);
mInflater = LayoutInflater.from(context);
mContext = context;
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
final ViewHolder holder = (ViewHolder)view.getTag();
//TODO: REMOVE AFTER IMPLEMENTING REAL IMAGE
int w = 24, h = 24;
Bitmap.Config conf = Bitmap.Config.ARGB_8888; // see other conf types
Bitmap bmp = Bitmap.createBitmap(w, h, conf); // this creates a MUTABLE bitmap
//END REMOVE
holder.hImage.setImageBitmap(bmp);
holder.hTextNaslov.setText(cursor.getString(cursor.getColumnIndex(DataContract.Obavijesti.OBAVIJESTI_NASLOV)));
holder.hTextOpis.setText(cursor.getString(cursor.getColumnIndex(DataContract.Obavijesti.OBAVIJESTI_OPIS)));
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View view=mInflater.inflate(R.layout.fragment_obavijesti_row,parent,false);
final ViewHolder holder = new ViewHolder();
holder.hTextOpis = (TextView) view.findViewById(R.id.obOpis);
holder.hTextNaslov = (TextView) view.findViewById(R.id.obNaslov);
holder.hImage = (ImageView) view.findViewById(R.id.oblist_image);
view.setTag(holder);
return view;
}
誰でも私を助けることができますか?