在Android中设置样式上的TableRow [英] Set style on TableRow in Android

查看:1517
本文介绍了在Android中设置样式上的TableRow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Android SDK,似乎没有任何办法来设置样式上的表行。我想要做的是等效的:

Using the Android SDK, there doesn't seem to be any way to set the style on a table row. I want to do the equivalent of:

<TableRow
    style='@style/TableRow_classic' >

在code。我想是这样的:

in code. I would like something like:

TableRow row = new TableRow(this);
row.setStyle(R.style.TableRow_classic);

有谁知道怎么找呢?

Does anyone know how to find this?

推荐答案

我发现做到这一点,最好的解决办法是建立一个局部的布局重新presenting表列,定义的风格:

The best solution I've found to accomplish this is to create a "partial" layout representing the table row, with a style defined:

<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    style="@style/tr_withborder" />

然后夸大它在你的code,动态使用:

Then inflate it in your code, to use dynamically:

TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.partial_table_row, null);

虽然不理想,但它确实为我工作。

While not ideal, it does work for me

这篇关于在Android中设置样式上的TableRow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆