Android Atualizando Fragment View após AsyncTask
Eu estou tentando atualizar fragmento de lista quando umAsyncTask
na minha atividade completa, mas não tenho certeza se estou fazendo algo errado. Atualmente, tenho um botão que inicia oAsyncTask
:
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
}
}
});
Quando minha execução terminar, tenho que instanciar um fragmento dentro da minha atividade:
ResultFragment resultfrag = new ResultFragment();
getSupportFragmentManager().beginTransaction()
.replace(R.id.content_frame, resultfrag).commit();
No entanto, ele não parece substituir meu conteúdo pelo fragmento da lista. Aqui está o meu arquivo de layout:
<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>