Xaloju
Xaloju

Reputation: 195

Why some TableLayout rows are not becoming invisible?

Depending on the Spinner selection, my replaced table should change to invisible, but if it's larger than the new table some old rows still being shown. When I select again the same option it disappears properly.

Example CODE

        Spinner s;
        s.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
            // your code here
            textSpinner = s.getSelectedItem().toString();
            switch (position){
                case 0:
                    tableLayout2.setVisibility(View.INVISIBLE);
                    tableLayout1.setVisibility(View.VISIBLE);
                    break;
                case 1:
                    tableLayout1.setVisibility(View.INVISIBLE);
                    tableLayout2.setVisibility(View.VISIBLE);
                    break;
            }
        }

Upvotes: 0

Views: 48

Answers (1)

earthw0rmjim
earthw0rmjim

Reputation: 19417

Cannot pinpoint the exact problem without seeing your code and layout, but using View.GONE instead of View.INVISIBLE might just work:

switch (position){
    case 0:
        tableLayout2.setVisibility(View.GONE);
        tableLayout1.setVisibility(View.VISIBLE);
        break;
    case 1:
        tableLayout1.setVisibility(View.GONE);
        tableLayout2.setVisibility(View.VISIBLE);
        break;
}

Upvotes: 2

Related Questions