我需要仅使用文件名来显示图像,而不是使用资源ID.
ImageView imgView = new ImageView(this);
imgView.setBackgroundResource(R.drawable.img1);
Run Code Online (Sandbox Code Playgroud)
我在drawable文件夹中有图像img1.我希望从文件中显示该图像.
我怎样才能做到这一点?
对jQuery很新.我正在尝试编写一个函数,如果打开/关闭开关(绿色),则会更改div中的文本.我不确定为什么这不起作用.这是我尝试过的:
$(document).ready(function() {
if ($('.slider').is(':checked')) {
changeText();
}
});
function changeText() {
('#screen span').text('00');
}
Run Code Online (Sandbox Code Playgroud)
这是相关的CSS:
.switch {
position: relative;
display: inline-block;
width: 56px;
height: 26px;
bottom: 95px;
left: 85px;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #990000;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 22px;
width: 26px;
left: 2px;
bottom: 2px;
background-color: white;
transition: .4s;
}
input:checked + .slider {
background-color: #00b300;
}
Run Code Online (Sandbox Code Playgroud)
这是相关的html:
<div …Run Code Online (Sandbox Code Playgroud)