0

我可以毫无问题地编辑或删除单个项目,但是当我在编辑项目后单击删除按钮时,即使它已从数据库中删除,该项目仍显示在 ListView 上。

ListViewActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.all_requests);

    requestsList = new ArrayList<HashMap<String, String>>();

    new LoadAllRequests().execute();

    ListView lv = getListView();

    lv.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            // getting values from selected ListItem
            String request_id = ((TextView) view.findViewById(R.id.request_id)).getText().toString();

            // Starting new intent
            Intent in = new Intent(getApplicationContext(),
                    ViewRequestActivity.class);
            // sending rid to next activity
            in.putExtra(TAG_ID, request_id);

            // starting new activity and expecting some response back
            startActivityForResult(in, 55);
        }
    });

}
4

3 回答 3

1

您必须再次将适配器签名到列表视图

于 2012-08-03T14:43:00.943 回答
1

您应该使用invalidateViews而不是关闭并重新打开活动

yourListView.invalidateViews();
于 2012-08-03T14:24:03.970 回答
0

您也可以尝试刷新活动。我相信它是 ListViewActivity.restart();

于 2012-08-03T15:03:30.077 回答