gpt4 book ai didi

java - 已删除的项目仍显示在“结果”页面上。

转载 作者:行者123 更新时间:2023-12-02 07:39:18 25 4
gpt4 key购买 nike

我可以毫无问题地编辑或删除单个项目,但是当我在编辑项目后单击删除按钮时,该项目仍然显示在 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);
}
});

}

最佳答案

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

yourListView.invalidateViews();

关于java - 已删除的项目仍显示在“结果”页面上。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11797360/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com