Skip to content Skip to sidebar Skip to footer

How To Clear Content On The Layout?

I just create a app for writing the text on Screen using TouchEvent method. It works fine. See this is code public TouchEventView(Context context, AttributeSet attrs) { super(c

Solution 1:

LinearLayoutlyt= (LinearLayout) findViewById(R.id.linearlayout);
lyt.removeAllViews();

Solution 2:

/*this is for clear viewgroup  here main is viewgroup          */if (null != main && main.getChildCount() > 0) {                 
    try {
        main.removeViews (0, main.getChildCount());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

Solution 3:

I've got the answer from (AndroidTechMe). I used onCreate(null) to clear the contents. Thanks mate.

Solution 4:

This should work

LinearLayout layout; // also works with other Layouts or ViewGroups
...
layout.removeAllViews();
// layout is cleared

Post a Comment for "How To Clear Content On The Layout?"