18 UI美化之level(等级显示显示)

  • 根据level显示哪张图片
  • 在工程文件的res/drawable/新建level-list

    如下
<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 0-10 显示这张 -->
<item android:drawable="@drawable/wifi1"
android:maxLevel = "10"
></item>
<!-- 20-30 之间显示 -->
<item android:drawable="@drawable/wifi2"
android:maxLevel = "20"
></item> <item android:drawable="@drawable/wifi3"
android:maxLevel = "30"
></item> <item android:drawable="@drawable/wifi4"
android:maxLevel = "40"
></item> </level-list>
  • 使用
package com.qf.day18_uiresources_demo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView; public class LevelActivity extends Activity { private ImageView iv; @Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState); setContentView(R.layout.activity_level); iv = (ImageView) findViewById(R.id.imageView1); } public void clickButton(View v) {
switch (v.getId()) {
case R.id.button1: iv.setImageLevel(10);
break; case R.id.button2: iv.setImageLevel(20);
break;
case R.id.button3: iv.setImageLevel(30);
break;
case R.id.button4: iv.setImageLevel(40);
break; }
}
}
上一篇:(诊断)处理错误fatal error: Python.h: No such file or directory


下一篇:python能够执行,但编译第三包遇到 python.h no such file or directory