Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
516 views
in Technique[技术] by (71.8m points)

android - How to clear all rows from a TableLayout?

I know that this has already been asked before, but none of the other responses have helped me, so I'll ask myself...

I am trying to delete all my existing rows from a TableLayout because I want the user to be able to update the table dynamically. Other suggestions have recommended using removeAllViews(), which is supposed to remove all child views, however this deletes rows from my other tables in the same LinearLayout (I have a linear layout with multiple tables).

Any suggestions?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It sounds like you might be calling removeAllViews() on the whole LinearLayout and not the particular TableLayout you want to clear. Double check you have some thing like:

myLinearLayout.someTableView.removeAllViews()


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...