in Education by
i'm working on an app for language studying. I want to display the translations directly underneath the foreign language words. I currently try to accomplish this by using a dynamically created table. But the table gets wider then display width and a lot of the table is out of view. I want to test if words will be put out of View and in this case continue writing these words in a new table beneath. How can I get the width of a table during runtime? I'm new to android programming. Do you maybe have a better Idea how to show the diffenternt language textes on screen? Resources res = getResources(); cn = res.getStringArray(R.array.lesson5_1_HanYu); py = res.getStringArray(R.array.lesson5_1_pinyin); dt = res.getStringArray(R.array.lesson5_1_deutsch); Intent in = getIntent(); int index = in.getIntExtra("com.example.ITEM_INDEX", -1); TableLayout tableLayout; TableRow tableRow1, tableRow2, tableRow3; TextView cn1TV, py1TV, dt1TV, cn2TV, py2TV, dt2TV, cn3TV, py3TV, dt3TV; TextView[] cnTV = new TextView[cn.length]; TextView[] pyTV = new TextView[py.length]; TextView[] dtTV = new TextView[dt.length]; if(index > -1){ tableLayout = new TableLayout(this); tableRow1 = new TableRow(this); tableRow2 = new TableRow(this); tableRow3 = new TableRow(this); TableLayout.LayoutParams lp = new TableLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); int i = 0; boolean lineEnd = false; while(i < cn.length && lineEnd == false){ cnTV[i] = new TextView(this); cnTV[i].setText(cn[i] + " "); pyTV[i] = new TextView(this); pyTV[i].setText(py[i] + " "); dtTV[i] = new TextView(this); dtTV[i].setText(dt[i] + " "); tableRow1.addView(cnTV[i]); tableRow2.addView(pyTV[i]); tableRow3.addView(dtTV[i]); // Check if next string is still in DisplayView area: // Code ... // change value of lineEnd if necessary i++; // proceed with next element in next interation } tableLayout.addView(tableRow1); tableLayout.addView(tableRow2); tableLayout.addView(tableRow3); setContentView(tableLayout); } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
This is a code sample from one of my projects where I measure a textview. You would measure a TableRow TextView filter = findViewById(R.id.list_filter); filter.measure(0, 0); int center = filter.getLeft() + filter.getMeasuredWidth()/2; Point p = new ViewTarget(filter).getPoint(); Log.i(TAG, "x: " + p.x + " width: " + filter.getWidth() + " right: " + filter.getRight() + " left: " + filter.getLeft() + " measured: " + filter.getMeasuredWidth() ); Log.i(TAG, "value: " + (0- filter.getLeft() - filter.getMeasuredWidth()));

Related questions

0 votes
    I have the access to this DOM node in temp1.$el. And here is the content which the above variable ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    I have the access to this DOM node in temp1.$el. And here is the content which the above variable ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    I have the access to this DOM node in temp1.$el. And here is the content which the above variable ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I have user control named DateTimeUC which has two textboxes on its markup: I am dynamically creating this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 13, 2022 in Education by JackTerrance
0 votes
    I have user control named DateTimeUC which has two textboxes on its markup: I am dynamically creating this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 13, 2022 in Education by JackTerrance
0 votes
    I have user control named DateTimeUC which has two textboxes on its markup: I am dynamically creating this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 13, 2022 in Education by JackTerrance
0 votes
    I have been developing a webpage which uses n number of dropdownlists which are binding dynamically inside a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    I have a problem with table-layout:fixed and width of inner columns if their content wider than column. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    What is not true in context of HTML tag ? O Table cell changes its width automatically based on content O We can ... table border is o Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    How will you get a space-padded string with the original string left-justified to a total of width colon?...
asked Nov 25, 2020 in Technology by JackTerrance
0 votes
    This is part of the component : import MyComp from '../../lib/MyComp' const Data = ( { data } ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    This is part of the component : import MyComp from '../../lib/MyComp' const Data = ( { data } ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    Background: I have an old web CMS that stored content in XML files, one XML file per page. I am ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 10, 2022 in Education by JackTerrance
0 votes
    I wanted to reduce the width of the columns so that become fit. The table is irregular due to with some columns ... , value = record ) Select the correct answer from above options...
asked Jan 17, 2022 in Education by JackTerrance
...