nullPointerException in multi column list

故事扮演 提交于 2019-12-01 21:14:17

Try using ListView

Instead of TableLayout add ListView to your xml and place the content on table in new xml Create an adapter by extending ArrayAdapter and set this adapter on your listView.

Don't add the views in your Java code, as they are added based on your XML file. It looks to me like your Java code is duplicating what you did in XML which is very precarious...

I don't see why you can't just remove the Java code and use setContentView to use the XML layout you defined.

Set the width to 0, and add weight as 1 for all the testviews, it will evenly assign space for every item in the row.

    textView1.setWidth(0);
    textView1.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!