On Sat, Aug 18, 2012 at 2:20 AM, Budd <[email protected]> wrote:

> Hi,
>
> I got a question about how to change to view dymaically.
>
> I have a empty FrameLayout in my activity.
>
> I want to do is every 10 seconds
> 1) Remove all the view in the layout
> 2) create new videoview or webview (depend on what kind of content in the
> array)
> 3) Add it to the layout
>
> Any suggestion how i should do it to avoid memory leak or etc?
>
>
You can do something like this as follows:


 img=new ImageView(this);
        img.setLayoutParams(new
inearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
        img.setImageResource(R.drawable.logo);

 btn = (Button)findViewById(R.id.btn);

       btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
           linearLayout.removeAllViews();
            if(ll.getChildAt(0)==null)
            {
               linearLayout.addView(img);
            }

            }
        });

I have done this on button click, you can do the similar using thread.

With Regards,
NSR

-- 
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

Reply via email to