小编nol*_*fra的帖子

如何在焦点和单击上更改ListView项目的颜色

我在我的应用程序中有一个列表视图(这是xml布局):

   <?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
       android:id="@+id/arrayList"
       android:layout_width="fill_parent"
android:layout_height="fill_parent"
       android:textFilterEnabled="true"
       android:scrollbars="vertical"
       android:drawSelectorOnTop="true">
</ListView>
Run Code Online (Sandbox Code Playgroud)

我的列表View中的每个项目都由两个TextView组成:

    <?xml version="1.0" encoding="utf-8"?>
<TableLayout android:layout_width="fill_parent"
       xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/row_container"
       android:padding="5px" android:layout_height="wrap_content"
       android:background="@color/white" android:shrinkColumns="0">
               <TableRow>
               <TextView android:layout_height="wrap_content"
                       android:layout_width="wrap_content" android:layout_below="@+id/
description"
                       android:id="@+id/description"
                       android:textColor="@color/black"
                       android:scrollHorizontally="true"
                       android:singleLine="true"></TextView>
       </TableRow>
       <TableRow>
               <TextView android:layout_width="wrap_content"
                       android:layout_height="wrap_content" android:id="@+id/result"
                       android:textColor="@color/grey"
                       android:maxLines="1"
                       android:scrollHorizontally="true"></TextView>
       </TableRow>

</TableLayout>
Run Code Online (Sandbox Code Playgroud)

我正在以这种方式从ArrayAdapter填充我的listView:

public class Matches extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);        
    //set layout

    setContentView(R.layout.list_layout);
  // obtain reference to listview
  ListView listView = …
Run Code Online (Sandbox Code Playgroud)

android listview background-color listviewitem

27
推荐指数
3
解决办法
12万
查看次数

已禁用DropDownList razor mvc

在我的剃刀视图中,我使用下拉列表.我希望禁用此控件(不可选).

我的代码是:

<div class="field-list">@Html.DropDownListFor(model => model.LinguaCodiceMadre, Model.LinguaMadreList, new{ @disabled = "disabled" })</div>
Run Code Online (Sandbox Code Playgroud)

但它不起作用,我的控制始终启用.Html页面代码是:

<select name="LinguaCodiceMadre" id="LinguaCodiceMadre" data-val-length-max="10" data-val-length="The field LinguaCodiceMadre must be a string with a maximum length of 10." data-val="true">
    <option></option>
    <option value="sq">Albanian</option>
    <option value="de">German</option>
    <option value="en">English</option>
    <option value="fr">French</option>
    <option value="it">Italian</option>
    <option value="pt">Portuguese</option>
    <option value="ru">Russian</option>
    <option value="es">Spanish</option>
</select>
Run Code Online (Sandbox Code Playgroud)

没有"禁用"属性.

我的真正目标是有条件地启用/禁用下拉列表,如下所示:

<div class="field-list">@Html.DropDownListFor(model => model.LinguaCodiceMadre, Model.LinguaMadreList, new{@disabled=Model.IsDisabled ? "disabled" : "false"})</div>
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

我试过两个

new{@disabled=Model.IsDisabled ? "disabled" : "false"}
Run Code Online (Sandbox Code Playgroud)

new{disabled=Model.IsDisabled ? "disabled" : "false"}
Run Code Online (Sandbox Code Playgroud)

但没有,禁用属性不在html页面上呈现.

有人有想法吗?

c# html.dropdownlistfor razor asp.net-mvc-4

6
推荐指数
3
解决办法
4万
查看次数

在GlassFish Server中找不到JAX-RS资源

我一直在尝试使用NetBeans Ide创建一个简单的Restful WebService.
我的Java EE版本是:Java EE 7 Web.

我创建了一个新的Java Web应用程序,设置此ContexPath : /DukesAgeService.

现在,运行我的应用程序,浏览器显示我的Index.html页面:

http://localhost:8080/DukesAgeService/

所以,一切正常.

然后,我尝试使用RESTful Web服务向导创建一个简单的restful资源.

所以,我创建了这个类:

package firstcup.webservice;

import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PUT;

/**
 * REST Web Service
*
* @author nolanof
*/
@Path("dukesAge")
public class DukesAgeResource {

@Context
private UriInfo context;

/**
 * Creates a new instance of DukesAgeResource
 */
public DukesAgeResource() {
}

/**
 * Retrieves representation of an instance of firstcup.webservice.DukesAgeResource …
Run Code Online (Sandbox Code Playgroud)

java rest web-services glassfish jax-rs

6
推荐指数
1
解决办法
5742
查看次数

Scala函数部分应用

我试图了解函数部分应用程序在 Scala 中的工作原理。

为此,我构建了这个简单的代码:

object Test extends App {
  myCustomConcat("General", "Public", "License") foreach print

  GeneralPublicLicenceAcronym(myCustomConcat(_)) foreach print

  def myCustomConcat(strings: String*): List[Char] = {
    val result = for (s <- strings) yield {
      s.charAt(0)
    }

    result.toList
  }


  def GeneralPublicLicenceAcronym (concatFunction: (String*) => List[Char] ) = {

    myCustomConcat("General", "Public", "License")
  }
}
Run Code Online (Sandbox Code Playgroud)

myCostumConcat函数接受输入一个字符串数组,并返回一个包含每个字符串的第一个字母的列表。

所以,代码

myCustomConcat("General", "Public", "License") foreach print
Run Code Online (Sandbox Code Playgroud)

将在控制台上打印:GPL

现在假设我想编写一个函数来生成 GPL 缩写词,使用(作为输入参数)我之前的函数提取每个字符串的第一个字母:

def GeneralPublicLicenceAcronym (concatFunction: (String*) => List[Char] ): List[Char] = {

    myCustomConcat("General", "Public", "License")
  }
Run Code Online (Sandbox Code Playgroud)

使用部分应用程序运行这个新函数: …

scala partialfunction

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