我在public void changeFragment(BaseFragment fragment, boolean addToBackStack, boolean preventDuplicate) {
Fragment topFragment = getSupportFragmentManager().findFragmentById(fragmentContainer.getId());
if (preventDuplicate && topFragment != null && fragment.getClass().equals(topFragment.getClass())) {
//Prevent adding same fragment
return;
}
FragmentTransaction transaction =
fragmentManager
.beginTransaction()
.replace(fragmentContainer.getId(), fragment);
if (addToBackStack) {
transaction.addToBackStack(null);
}
transaction.commit();
}
public void goToHome() {
fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
}
目录中有.png
张图片。知道我想以编程方式将此图像设置为mipmap
背景。并在一些过程后删除它。
linearLayout
我应该使用哪种功能?
这可以改变背景颜色:
target SDK : 23
min SDK : 14
但背景图片在哪里?
答案 0 :(得分:5)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
<li><a class="nav-item" href="#"><span>Quality</span></a></li>
<li><a class="nav-item" href="#"><span>Safety</span></a></li>
<li class="active"><a class="nav-item" href="#"><span>People</span></a></li>
<li><a class="nav-item" href="#"><span>Cost</span></a></li>
<li><a class="nav-item" href="#"><span>Delivery</span></a></li>
</ul>
或
ll.setBackgroundResource(R.mipmap.my_image);
答案 1 :(得分:0)
两者都在运作
iv_pic_image.setImageResource(R.mipmap.generic_product_4);
or
iv_pic_image.setImageDrawable(getResources().getDrawable(R.mipmap.generic_product_4));