Re: [android-developers] List of views to change in layout
On Sat, Aug 18, 2012 at 2:20 AM, Budd <buddfung@gmail.com> wrote:
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
-- 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 seconds1) Remove all the view in the layout2) create new videoview or webview (depend on what kind of content in the array)3) Add it to the layoutAny 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home