ListView가있는 Android 앱이 있습니다. 모든 행은 SQLIte 쿼리 결과에 따라 동적으로 생성됩니다. 사용자가 항목을 클릭하면 앱은 해당 항목의 '콘텐츠'로 목록을 새로 고쳐야하고 다른 SQLite 쿼리에 의해 생성되어야합니다. 새로운 의도를 작성하고 동일한 활동으로 보내는 활동을 "새로 고"하려고했습니다. 활동 이름이 이런 식으로 로그 캣에서 ShopActivityListView 새로 고침 방법
ListView list_content = ((ListView)findViewById(R.id.listforshop)); list_content.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // ID and text of selected item long selected_id = id; String selected_name = (String) ((TextView) view.findViewById(R.id.element)).getText(); // New intent Intent intent = getIntent(); intent.setClassName(ShopActivity.this, ShopActivity.class.getName()); // Passing data and refreshing activity intent.putExtra("id", selected_id); intent.putExtra("name", selected_name); intent.putExtra("type", ""); startActivity(intent); } });
인 나에게 번들에 대한 경고를 많이 보여줍니다. 앱이 활동을 시작할 수없는 것 같습니다.
ListView를 "새로 고치는"다른 방법이 있습니까? 이 구현이 정확합니까?
목록 데이터를 업데이트해야하는 경우 어댑터에서 notifyDataSetChanged()를 호출하고 ListView에서 invalidate()를 시도하여 뷰 자체가 다시 그려 지도록 요청하십시오 –