xml文件:
<TextView
android:id="@+id/checkupdate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawableRight="@drawable/plugins_menses_swich_closed"
android:padding="10dip"
android:text="新版本检测"
android:textSize="20dip" />
第一步:获取textView
passstyle = (TextView) v.findViewById(R.id.passstyle);
第二步:
Drawable img;if (bpass) {
img = getActivity().getResources().getDrawable(
R.drawable.plugins_menses_swich_open);
passstyle.setText("手势锁");
} else {
passstyle.setText("文字锁");
img = getActivity().getResources().getDrawable(
R.drawable.plugins_menses_swich_closed);
}
img.setBounds(0, 0, img.getMinimumWidth(), img.getMinimumHeight());
passstyle.setCompoundDrawables(null, null, img, null); // 设置左图标