I have one problem with customized dialog box in android,i have created the
customized dialog using javainterface in android ,in my class
CustomizeDialog i have one thread do some process in back ground after that
i have set one imgae to this customized dialog i set the image in
OnPostExecute but i got the following error
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the
original thread that created a view hierarchy can touch its views.
i know we can't access the main ui from another thread but we access the
main ui in OnPostExecuted in my case that also not working ,
in my another class(main.class) i will call this class by
CustomizeDialog customizeDialog = new CustomizeDialog(mContext);
customizeDialog.show();
this my code which create dialog box
public class CustomizeDialog extends Dialog implements OnClickListener {
Button okButton;
ImageView img = null;
ImageView img2=null;
ImageView img3 = null;
ImageView img4= null;
Bitmap bm;
public CustomizeDialog(Context context) {
super(context);
img2 = (ImageView) findViewById(R.id.imageView1);
img3 = (ImageView) findViewById(R.id.imageView3);
img4 = (ImageView) findViewById(R.id.imageView4);
WindowManager.LayoutParams params = getWindow().getAttributes();
params.x = 30;
params.height = 500;
params.width = 500;
params.y = 50;
this.getWindow().setAttributes(params);
setContentView(R.layout.test);
img = (ImageView) findViewById(R.id.imageView2);
img.setBackgroundResource(R.drawable.sample);
AnimationDrawable frameAnimation = (AnimationDrawable)
img.getBackground();
//Start the animation (looped playback by default).
frameAnimation.start();
new LongOperation1(context).execute("");
}
else
{
Toast toast = Toast.makeText(getContext(), "Erorr",
Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
} }
private class LongOperation1 extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... params) {
//here i do some process
return "Executed";
}
@Override
protected void onPostExecute(String result) {
// here i do some process to get bm
img2.setImageBitmap(bm);
}
@Override
protected void onPreExecute() {
}
@Override
protected void onProgressUpdate(String... values) {
}
}
do any have idea about how to do this
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en