how to remove a view

how to remove a view

by hackbod » Thu, 11 Sep 2008 14:49:58 GMT

setContentView() replaces any existing views. If you want finer-
grained control, you can setContentView() a top-level layout manager,
which you can then add and remove views in as you desire.
--~--~---------~--~----~------------~-------~--~----~

how to remove a view

by Billsen » Sat, 13 Sep 2008 02:23:06 GMT

Would you please provide a little more information? I loaded
R.layout.main by setContentView(), then added a view with
addContentView. I need to remove the view added by addContentView by
clicking a button.
Thanks,
Billsen
--~--~---------~--~----~------------~-------~--~----~

how to remove a view

Re: how to remove a view

by Guilo » Fri, 20 May 2011 04:29:40 GMT

I know it is old but I have the same problem. I want next to change the view
added by addContentView. Indeed recalling addContenView throws an Exception
:
05-19 22:28:31.785: ERROR/AndroidRuntime(11210):
java.lang.IllegalStateException: The specified child already has a parent.
You must call removeView() on the child's parent first.
--

Hi out there! I just started coding with androids a couple of days
ago. Now i want to create a new textfield that returns something to
the use on a certain buttonclick, well it doesn't work.
here is the code:
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class myhello extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v)
{
TextView tv = new TextView(); // I dont know which context i
need to pass here...
tv.setText("You pushed the button!");
setContentView(tv);
}
} );
}
}
I'd appreciate any help!
thanks superphil0
--~--~---------~--~----~------------~-------~--~----~

Hello,
Has anybody figure out what "com.example.android.apis.Path" in class
ApiDemos method onCreate do? Any documentation on its purpose and any
other variables or constants that are grouped with it?
Regards,
Yek-Chong
--~--~---------~--~----~------------~-------~--~----~