Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid: two issues using Tablerow+TextView in Tablelayout
    primarykey
    data
    text
    <p>I am using Tablerow+TextView to make a simple view for blog posts and their replies. In each TableRow I put a TextView in. Now I have two issues:</p> <ol> <li><p>The text which is longer than the screen won't automatically wrap up to be multi-line. Is it by design of TableRow? I've already set <code>tr_content.setSingleLine(false);</code> [update] This has been addressed, I think I should change Fill_parent to be Wrap_content in textView.<code>tr_author_time.setLayoutParams(new LayoutParams( LayoutParams.**WRAP_CONTENT**, LayoutParams.WRAP_CONTENT));</code></p></li> <li><p>The Table won't scroll like ListView. My rows are more than the screen size. I expect the table could be scrolled down for viewing just like ListView. Is that possible?</p></li> </ol> <p>Here is my code:</p> <pre><code> TableLayout tl = (TableLayout) findViewById(R.id.article_content_table); TextView tr_title = new TextView(this); TextView tr_author_time = new TextView(this); TextView tr_content = new TextView(this); TableRow tr = new TableRow(this); for(int i = 0; i &lt; BlogPost.size(); i++){ try{ // add the author, time tr = new TableRow(this); /////////////////add author+time row BlogPost article = mBlogPost.get(i); tr_author_time = new TextView(this); tr_author_time.setText(article.author+"("+ article.post_time+")"); tr_author_time.setTextColor(getResources().getColor(R.color.black)); tr_author_time.setGravity(0x03); tr_author_time.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); tr.addView(tr_author_time); tl.addView(tr,new TableLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); ////////////////////// then add content row tr = new TableRow(this); tr_content = new TextView(this); tr_content.setText(article.content); tr_content.setSingleLine(false); tr_content.setGravity(0x03); tr_content.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); tr.addView(tr_content); tr.setBackgroundResource(R.color.white); tl.addView(tr,new TableLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload