-
-
Save codingwithsara/9582325811226d96eedd70f296181c17 to your computer and use it in GitHub Desktop.
【Android Studio Tips】TableLayout – Border & Collapse –
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.codingwithsara.tabletest; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.TableLayout; | |
public class MainActivity extends AppCompatActivity { | |
private boolean table_flg = false; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
} | |
public void collapseTable(View view) { | |
TableLayout table = findViewById(R.id.table); | |
Button switchBtn = findViewById(R.id.switchBtn); | |
// setColumnCollapsed(int columnIndex, boolean isCollapsed) | |
table.setColumnCollapsed(1, table_flg); | |
table.setColumnCollapsed(2, table_flg); | |
if (table_flg) { | |
// Close | |
table_flg = false; | |
switchBtn.setText("Show Detail"); | |
} else { | |
// Open | |
table_flg = true; | |
switchBtn.setText("Hide Detail"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment