Problem: When the TextView within a TableRow is populated with a user selected path and filename, if the length is too long, it forces the adjacent Views within the TableRow to disappear. The TableRows and Views within the TableLayout are created programmatically through Java, not through the activity layout XML, and I'm having difficulty figuring out how to "fix the size" of one of these two column views within the TableLayout/TableRow, even if the path and filename run off the right edge of the TextView or switch to multi-line.
What I have tried: I'm not totally unfamiliar with creating TableLayouts and related TableRows and Views through the activity layout xml. Doing so programmatically I'm not as familiar with. I have searched and posted to StackOverflow, performed some research with other user posted tutorials and posts, but nearly 100% deal with xml programming, not Java manipulation. I've tried inferring from those examples how to I might do so in the Java TableRow, Button and TextView objects, but I'm not having any success. I think I'm lacking an understanding between when to use the TableRow vs. Button and TextView layout parameters (e.g., width/height/match_parent/wrap_content). Anyhow, I'm stuck and can't seem to grasp the proper logic and hoping someone may be able to help me better understand how to achieve my intentions.
Background on functionality: The Android activity layout (xml) creates what might be called a "TableLayout placeholder" within the activity that can be programmitically referenced and manipulated upon user button clicks. As a result, I have a singleton class that holds methods called when a user clicks either an "Add" button or "Delete" ( - ) button. When a user clicks the add button, it launches an Intent for selecting a file, based upon the user's selection, adds a new TableRow with a Delete Button view and a TextView with the path and filename. The Delete button removes the entire row if the user decides to remove it. The Add and Delete button functionality works, I just can't get the views to fit properly since I'm having to learn how to adjust them through Java programmatically.
What I'm trying to do: Using Java, I'm trying to "fix" the size of the Delete button (i.e., " - ") (Column 1) so it remains within the TableRow to the left, and allow the TextView to fill the remainder of the TableRow width, which in the end depends upon the type of phone and TableLayout width).
Below are a couple before and after images and code that I'm using to create the TableRows and related views (also see StackOverflowStackOverflow Post).
Activity Layout - TableLayout
The click of the "Add" button will launch this method's "else" statement to add a TableRow with 2 views (Button, TextView), which are two method calls following:
The methods called to create views for the delete Button and TextView:
I think the first question to ask would be: why does the entire path need to be displayed? Do the users really get value out of seeing the whole "storage/emulators..." string? I'd guess that few of them would have delved deep enough into Android to make sense of that.
I was able to find some help by using the word "dynamically" instead of "programmatically." I discovered I did not to set LayoutParams for the TableRow itself (e.g., row.setLayoutParams()). Once I set these, I was able to set separate parameters for each cell item.