一位同事告诉我这个:
他有一个DropDownList和一个网页上的按钮.这是背后的代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ListItem item = new ListItem("1");
item.Attributes.Add("title", "A");
ListItem item2 = new ListItem("2");
item2.Attributes.Add("title", "B");
DropDownList1.Items.AddRange(new[] {item, item2});
string s = DropDownList1.Items[0].Attributes["title"];
}
}
protected void Button1_Click(object sender, EventArgs e)
{
DropDownList1.Visible = !DropDownList1.Visible;
}
Run Code Online (Sandbox Code Playgroud)
在页面加载时,项目的工具提示正在显示,但在第一次回发时,属性将丢失.为什么会这样,有没有解决方法?
我想<li>在特定位置添加一个,例如:
<ul id="list">
<li>Position 1</li>
<li>Position 2</li>
<li>Position 4</li>
<ul>
Run Code Online (Sandbox Code Playgroud)
假设我想在<li>下面/后面添加一个新的<li>Position 2</li>,我怎么能用jQuery做呢?
我试过使用下面的代码:
$('#list li:eq(1)').append('<li>Position 3</li>');
Run Code Online (Sandbox Code Playgroud)
但是,它没有用,因为它附加在<li>里面<li>Position 2</li>,而不是添加<li>下面/后面<li>Position 2</li>.
有人可以给我一些帮助吗?
谢谢.
这是我的listview点击事件:
lv1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Object o = lv1.getItemAtPosition(position);
ItemDetails obj_itemDetails = (ItemDetails)o;
Toast.makeText(ListViewImagesActivity.this, "You have chosen : " + " " + obj_itemDetails.getName(), Toast.LENGTH_LONG).show();
}
});
Run Code Online (Sandbox Code Playgroud)
这是我的按钮点击事件:
btnNxt = (Button) findViewById(R.id.btnNext);
btnNxt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
//Here I need to get that position
});
Run Code Online (Sandbox Code Playgroud)
现在我需要获得点击的listview项目的位置..我已经全局声明了postion但总是给我位置1.
谁能说我怎么得到这个位置?
android listitem buttonclick android-listview android-button
很简单的问题,但我不确定是否可能.我想添加一个图像作为所有<h1>元素中的子弹.我知道我可以通过以下方式实现:
<span class='bullet'></span><h1>My H1 text here</h1>
Run Code Online (Sandbox Code Playgroud)
用css:
.bullet{
background: url('bullet.png') no-repeat;
display:inline-block;
vertical-align: middle;
background-size:100%;
height:25px;
width:25px;
margin-right: 5px;
}
Run Code Online (Sandbox Code Playgroud)
但有没有一种自动的方法来做同样的事情?我想的是:
h1{
list-style-image: url('bullet.png');
}
Run Code Online (Sandbox Code Playgroud)
但这似乎只适用于<ul>元素.我真的不想在<span>元素之前到处粘贴<h1>元素.有任何想法吗?
是否可以改变<li>元素子弹的大小?
看看下面的代码:
li {
list-style: square; // I want to change the size of this squared bullet.
}
Run Code Online (Sandbox Code Playgroud)
我似乎无法找到任何方法来实现这一目标.
我刚刚遇到这种奇怪的事情,我期望以不同的(逻辑的)方式工作,但事实并非如此.这是一个错误还是一个"功能"?
所以有一个DropDownList,我在Listbehind中使用ListItem列表填充.每个新的ListItem都有2个参数,根据intellisense提供的文档,它们对应于它的文本和值:
List<ListItem> users = new List<ListItem>();
foreach (SubscriptionUser su in subscriptionDetails.UserList)
{
users.Add(new ListItem(su.FirstName + " " + su.LastName, su.EmailAddress));
}
ddlPrimaryContact.DataSource = users;
ddlPrimaryContact.DataBind();
Run Code Online (Sandbox Code Playgroud)
现在,有人可以解释为什么数据绑定DropDownList将Text和Value设置为完全相同(ListItem文本)而不是使用ListItem.Text作为Text和ListItem.Value作为值?
哎呀!http://www.freeimagehosting.net/uploads/fe65d0e7d5.jpg
或者我做错了什么?
我有一个菜单<ul>.每个菜单项都是a <li>并且当前可单击.基于某些条件,我想禁用(使其不可点击)特定<li>元素.我怎样才能做到这一点?我尝试使用disabled的属性<li>,并list-style:none为好.都没有奏效.有什么建议?
有没有办法在单选按钮列表中的输入项上设置CSS类?我想在jQuery中按类引用这些表单值.
给定一个ASP.NET RadioButtonList,在ListItems上设置类:
<asp:RadioButtonList ID="RadioButtonList" runat="server">
<asp:ListItem class="myClass" Text="Yes" Value="1" />
<asp:ListItem class="myClass" Text="No" Value="0" />
</asp:RadioButtonList>
Run Code Online (Sandbox Code Playgroud)
将呈现为:
<span id="RadioButtonList" class="radioButtonListField myClass">
<span class="myClass">
<input id="RadioButtonList_0" type="radio" value="1"
name="RadioButtonList"/>
<label for="RadioButtonList_0">Yes</label>
</span>
<span class="myClass">
<input id="RadioButtonList_1" type="radio" value="0"
name="RadioButtonList"/>
<label for="RadioButtonList_1">No</label>
</span>
</span>
Run Code Online (Sandbox Code Playgroud)
不幸的是,"myClass"类被添加到<span>包含单选按钮项而不是它<input>自身.我怎么能让它看起来像这样:
<span id="RadioButtonList" class="radioButtonListField myClass">
<span>
<input id="RadioButtonList_0" class="myClass" type="radio" value="1"
name="RadioButtonList"/>
<label for="RadioButtonList_0">Yes</label>
</span>
<span>
<input id="RadioButtonList_1" class="myClass" type="radio" value="0"
name="RadioButtonList"/>
<label for="RadioButtonList_1">No</label>
</span>
</span>
Run Code Online (Sandbox Code Playgroud)
(这甚至没有涉及将类添加到动态绑定RadioButtonLists的问题.)
<div class="imgcontainer">
<ul>
<li><img src="1.jpg" alt="" /></li>
<li><img src="2.jpg" alt="" /></li>
.....
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
我通过创建无序列表编写一个简单的图库页面,它的每个列表项都包含一个图像.
ul li {
float: left;
}
Run Code Online (Sandbox Code Playgroud)
我将容器的宽度设置为"max-width",这样我就可以使列表项(图像)适合浏览器宽度..这意味着当浏览器窗口重新调整大小时,它们将被重新排列.
.imgcontainer{
max-width: 750px;
}
Run Code Online (Sandbox Code Playgroud)
现在问题是那些图像或列表项没有对齐到中心,它们对齐到.imgcontainer体的左侧(在下面的附加链接中为灰色),当窗口重新调整大小时在右侧留下空格!

每次窗口调整大小时,如何将这些图像居中?
这是您可以在JS Bin上预览或编辑的整个页面/代码
我创建了一个包含标题和副标题的listitem.看看结果,我觉得它看起来并不专业.所以这就是我要问的原因.
我正在寻找的列表项很常见(它在很多应用程序中使用,即Android的默认设置菜单,当你在eclipse的图形布局编辑器选项卡中添加listview时也会显示它).
所以我的问题是:在哪里可以找到带有标题和副标题的listitem的默认布局?
listitem ×10
css ×5
asp.net ×3
html-lists ×3
android ×2
append ×1
behavior ×1
buttonclick ×1
center ×1
css-float ×1
data-binding ×1
gallery ×1
html ×1
java ×1
javascript ×1
jquery ×1
list ×1
postback ×1
size ×1