小编use*_*402的帖子

android listview交替行颜色但是默认光标选择

我已经遍布网络,包括stackoverflow,似乎无法得到一个明确的完整方式

我想创建一个ListView

1)有交替的颜色(我可以用下面的代码做到这一点)2)保留android的默认橙色选择行为

完成#1我有一个扩展ArrayAdapter的自定义适配器,然后我像这样重写getView

public View getView(int position,  View convertView,   ViewGroup parent)
{
  ....

  // tableLayoutId is id pointing to each view/row in my list
  View tableLayoutView = view.findViewById(R.id.tableLayoutId); 
  if(tableLayoutView != null)
  {
      int colorPos = position % colors.length;
      tableLayoutView.setBackgroundColor(colors[colorPos]);
  }
}
Run Code Online (Sandbox Code Playgroud)

我的颜色成员变量是

private int[] colors = new int[] { 0x30ffffff, 0x30ff2020, 0x30808080 };
Run Code Online (Sandbox Code Playgroud)

此处找到文章"Android - 在ListView中使用SimpleAdapter应用备用行颜色"

现在这是我被卡住的地方,我在stackoverflow上看到一些提到这样做,因为它会看到常见的,他们建议将此属性添加到

机器人:listSelector = "@颜色/ LIST_ITEM"

list_item.xml就像这样

<selector xmlns:android="http://schemas.android.com/apk/res/android">
   <item android:state_selected="true"
    android:drawable="@drawable/transparent" />
   .....
 </selector>
Run Code Online (Sandbox Code Playgroud)

然后我必须向getView()添加代码以确定我所处的状态并采取相应的行动.

有没有一个例子让这个工作?谢谢大家,我很乐意发布我的所有内容,如果我可以让它工作.:-(

android listview row colors alternate

3
推荐指数
1
解决办法
3728
查看次数

xslt 错误:通过 xalan/java 通过 xsl/xslt 转换我的 xml 时出现额外非法标记:'eq'、''center''

我正在尝试使用 org.apache.xalan.xslt.Process 类通过 java/xalan (2.7.1) 转换我的 xml

我收到“额外非法令牌”,但不确定解决方法

我基本上想将参数传递给模板,然后使用该参数作为模板的属性<xsl:when test="$textAlign eq 'center'">

如果我将'center'参数传递到 TableCell 模板中,我想创建一个文本居中的表格单元格,当然,'left'会使其内容左对齐。

错误消息抱怨'center'

中心周围的报价使它出错,看起来应该没问题。

这里有一些片段(示例 xml 和 xsl)

    <ingredients>         
          <ingredient>
                <quantity>1 1/2</quantity>
                <foodstuff>flour</foodstuff>
          </ingredient>
    </ingredients>
Run Code Online (Sandbox Code Playgroud)

这是一个示例 xsl

<xsl:output method="html"/>
<xsl:template match="ingredients">
      <xsl:apply-templates select="ingredient"/>
</xsl:template>
.
<xsl:template match="ingredient">
  <xsl:call-template name="TableCell">
        <xsl:with-param name="cellValue" select="quantity" />
        <xsl:with-param name="textAlign" select="'center'" />
  </xsl:call-template>
</xsl:template>
.
<xsl:template name="TableCell">
  <xsl:param name="cellValue" />
  <xsl:param name="textAlign" />
  <xsl:choose>
      <xsl:when test="$textAlign eq 'center'">
      <td align='center'>
        <xsl:value-of select="$cellValue"/>
      </td>
    </xsl:when>
  </xsl:choose>
</xsl:template> …
Run Code Online (Sandbox Code Playgroud)

java xslt xalan

2
推荐指数
1
解决办法
3859
查看次数

标签 统计

alternate ×1

android ×1

colors ×1

java ×1

listview ×1

row ×1

xalan ×1

xslt ×1