내 활동의 AsyncTask
이 완료되었을 때 목록 조각을 업데이트하려고하는데 잘못된 작업을하고 있는지 확실하지 않습니다. 현재, 나는 시작 버튼이있는 AsyncTask
:AsyncTask 이후에 안드로이드 새로 고침 조각보기
search = (Button)findViewById(R.id.search);
search.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
String productname = prodname.getText().toString().trim();
if (NetworkManager.isOnline(getApplicationContext())){
// Go to Other screen
AsyncFetcher results = new AsyncFetcher(currActivity);
String _url = "http://192.168.1.3:3000/search.json?
utf8=%E2%9C%93&q="+productname;
// progressDialog = ProgressDialog.show(
// ClassifiedsActivity.this, "", "Loading...");
results.execute(_url);
} else {
// Throw some warning saying no internet
// connection was found
}
}
});
일단 내 내 활동 내에서 조각을 인스턴스화 다음 한 완료 실행 : 그것은 같지 않습니다 그러나
ResultFragment resultfrag = new ResultFragment();
getSupportFragmentManager().beginTransaction()
.replace(R.id.content_frame, resultfrag).commit();
이 함께 내 콘텐츠를 교체 목록 조각. 조각을 교체하는 것은 그것을 상쾌처럼 아무것도
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
안녕하세요, 감사합니다. 난 당신이 여기에 설명 된 방법을 추가하고도 추가했다 "m_adapter.clear(); \t \t m_adapter.notifyDataSetChanged(); \t \t m_adapter.addAll (this.search_results를);" 어댑터가 여전히 이전 "ArrayList"에 대한 참조를 보유하고 있으므로 새로 고침 데이터가 작동하도록 만듭니다. – user2352691
아 물론 그렇습니다. listView 및 해당 어댑터를 사용하여 처리하는 방법에 따라 다릅니다. 나는 네가 한 것을 기쁘게 생각한다. :) – yahya