我想自定义无序列表的项目呈现方式.
我知道我可以使用list-style-type来改变之间none,disc,circle,square等或多或少支持的值.我也知道可以将指定图像的列表标记的默认外观更改为list-style-image属性.
问题是我想用large right arrow(►,►)HTML特殊字符替换子弹而不是使用list-style-image三角形图像的组合.
可能吗?顺便说一句,如果这很重要jQuery已经加载到页面上,所以如果这可以帮助它就不会有问题.
谢谢.
- 编辑 -
谢谢,我将使用一个版本或另一个版本,具体取决于它需要支持哪个浏览器.顺便说一下,这两个答案都很棒并且必须判定哪一个是"赢家"并不容易,所以我选择了先给出的答案.
我有一个listview,可以自定义显示图像和2 textview.我只是想突出我列表中的一个项目.
首先,我使用listview的setSelection方法,我终于发现它不是因为它不在触摸模式下工作.
所以,我做了一些搜索,发现我需要使用setItemChecked方法.因此,我制作了一个状态列表颜色.
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@color/checkbox_bg_fcs" />
<item android:drawable="@color/WHITE" />
</selector>
Run Code Online (Sandbox Code Playgroud)
我用它来设置我的自定义列表项的背景颜色.
从List活动中,我将setItemChecked(position,true)调用到listview的特定索引.
不幸的是,它似乎对我不起作用.有什么遗漏?谁有运气呢?
注意**,我确实从网络中检索了列表视图的数据.我的listview中有数据之后才进行setItemChecked.
我的列表视图也是单选模式.
我试图在我的页面上获取所有下拉列表,并在每个下拉列表中选择所选项目文本/值.但我似乎错过了一些东西.
foreach (DropDownList dr in this.Page.Form.Controls.OfType<DropDownList>()) {
foreach (ListItem li in dr.Items) {
if (li.Selected) {
//put the selected items value/text into something.
}
}
}
Run Code Online (Sandbox Code Playgroud)
有没有想过这样做?
编辑:使其更清晰.我有一个随机数量的DropDownLists,我可以选择1个选项pr Dropdownlist.当我按下按钮时,我需要从每个DropDownLists中选择的内容中获取信息.(DropDownLists上没有ID,有一个随机数).
我遇到了一个烦人的问题,如果你不是像我这样的新手,那可能很容易解决.
我在ASP.Net中有一个DropDownList,它有一个需要被禁用的ListItem ......但我不是说DropDownList.而且我也不想禁用整个DropDownList,只需要一个特定的ListItem.我想说的是写在HTML的ListItem,是这样的...
<option disabled="disabled" value="-1">Disabled Option</option>
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何在ASP.Net中这样做?
非常感谢.
目前,当单击ListItem时,我抓住它的位置并将其传递给我的StopsScheduleActiviy.我想检测何时单击该ListItem的ImageView,以便我可以启动我的MapActivity并将其传递给位置.
基本上:单击ImageView启动MapsActivity,否则单击ListItem上的任何其他位置启动StopsScheduleActivity.在这两种情况下我都需要这个职位.我怎样才能做到这一点?
这是我当前的onItemClick监听器.
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent myIntent = new Intent(this, StopsScheduleActivity.class);
myIntent.putExtra("stop", stops.get(position));
startActivity(myIntent);
Log.i("Winnipeg Bus", "Stop item #" + id + " clicked.");
}
Run Code Online (Sandbox Code Playgroud)
这是我的ListView,其中包含我想要点击的ImageView地图.谢谢!

所以我有自定义列表项,带有ListView按钮.按下时,按钮显示交替可绘制以向用户显示反馈.但是,当我点击该行时,每个按钮都显示按下状态,就像我点击它们一样.
如何让按钮显示其原始状态而不是state_pressed?
布局/列表项目:
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:descendantFocusability="blocksDescendants" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:gravity="center_vertical|left" >
<TextView
android:id="@+id/txtMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
style="@style/PrimaryText" />
<TextView
android:id="@+id/txtSub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
style="@style/SecondaryText" />
</LinearLayout>
<ImageButton
android:id="@+id/imbResponse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:focusable="false"
android:duplicateParentState="false"
android:src="@drawable/response_btn"
android:contentDescription="@string/response"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="5dp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
绘制/ response_btn.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_focused="true" android:drawable="@drawable/res_m" />
<item android:state_pressed="true" android:drawable="@drawable/res_m" />
<item android:state_focused="false" android:state_pressed="false" android:drawable="@drawable/res_alt_m" />
</selector>
Run Code Online (Sandbox Code Playgroud)
我试图删除state_focused和state_pressed,state_focused.似乎该按钮从其父级获取state_pressed.
我有一个包含人员列表的列表框.当用户单击某个项时,viewModel应将currentPerson对象设置为用户单击的Object.
我必须为此使用ViewModel,因此MainWindow.xaml.xs中没有代码.任何想法如何解决这个问题?
我有一个下拉列表,我需要存储比标准列表项允许的更多数据.我采用的方法是为每个列表项添加一个属性.
我监视的变化,可以返回的SelectedIndex,但我不知道如何获取属性从那里回来,或者是否有实现这一目标的任何更简单的方法.
有任何想法吗?
我有一个ListBox,选择模式为multiple.在后面的代码中,我想将一些值设置为选中.这些值存在于名为"Names"的ListItems []中.
HTML代码:
<asp:ListBox ID="lbto" class="chosen" runat="server" Width="450px"
Height="20px" SelectionMode="Multiple">
<asp:ListItem>Mandy</asp:ListItem>
<asp:ListItem>Amit</asp:ListItem>
<asp:ListItem>sundar</asp:ListItem>
<asp:ListItem>ragu</asp:ListItem>
<asp:ListItem>raju</asp:ListItem>
</asp:ListBox>
Run Code Online (Sandbox Code Playgroud)
列表项[]的名称中包含"肉酱"和"拉朱".现在,页面加载时,在列表框应该包含"肉酱"和"拉朱"作为选择的值.
After knowing that a list-item element cannot be display: flex at the same time, I wrap my contents with a container, then put the container inside the <li />.
Things go right for elements with content.
However, if the first element in the container has no child nodes, the marker of the <li /> is unexpectedly located at the bottom.
Though in my case I can simply add a display: none to workaround, I'm still confused:
How can …