我想在 AsyncClass 的 OnPostMethod 中的 imageview 和 textview 中设置图像和文本,就像我在“后台执行”方法中做一些网络操作一样,并且在特定的响应中,我只想用特定的图像和文本填充 imageviews 和 textviews .
谁能告诉我如何在 OnPostMethod 中设置图像。我想知道是否有人可以告诉我我在以下代码中犯的错误
public class testing_async extends Activity {
private ProgressDialog progressDialog;
String s;
ImageView im;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.testing_async);
new GetCategoryList().execute(s);
im = (ImageView) findViewById(R.id.im1);
}
//
// THE AsyncTask Class for GetCategoryList....
//
class GetCategoryList extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
// showDialog(progress_bar_type);
progressDialog = ProgressDialog.show(testing_async.this, "",
"Loading...");
}
@Override
protected String doInBackground(String... f_url) {
/*
* LinearLayout layout = new LinearLayout(testing_async.this);
* layout = new LinearLayout(testing_async.this);
* layout.setLayoutParams(new ViewGroup.LayoutParams(
* ViewGroup.LayoutParams.FILL_PARENT,
* ViewGroup.LayoutParams.FILL_PARENT));
*
* RelativeLayout inner_layout = new
* RelativeLayout(testing_async.this); inner_layout = new
* RelativeLayout(testing_async.this); layout.setLayoutParams(new
* ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT,
* ViewGroup.LayoutParams.FILL_PARENT));
*
* ImageView im = new ImageView(testing_async.this);
* im.setImageResource(R.drawable.logo_background);
* RelativeLayout.LayoutParams layoutParams90 = new
* RelativeLayout.LayoutParams( 225, 250); layoutParams90.leftMargin
* = 45; layoutParams90.topMargin = 45;
* im.setLayoutParams(layoutParams90); inner_layout.addView(im);
* layout.addView(inner_layout);
*/
return null;
}
protected void onProgressUpdate(String... progress) {
}
@Override
protected void onPostExecute(String file_url) {
im.setBackgroundResource(R.drawable.back);
progressDialog.dismiss();
}
}
}