• Level List


    Level List

    用户管理图片需要相互切换显示。

    文件存放位置:
    res/drawable/

    语法:
    <?xml version="1.0" encoding="utf-8"?>
    <level-list
        xmlns:android="http://schemas.android.com/apk/res/android" >
        <item
            android:drawable="@drawable/drawable_resource"
            android:maxLevel="integer"
            android:minLevel="integer" />
    </level-list>

    用法:

    level_list_button_checkable.xml
    <?xml version="1.0" encoding="utf-8"?>
    <level-list xmlns:android="http://schemas.android.com/apk/res/android" >
        <item
            android:drawable="@drawable/checkbox"
            android:maxLevel="0" />
        <item
            android:drawable="@drawable/checkbox_selected"
            android:maxLevel="1" />
    </level-list>
    layout_level_list.xml:
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:background="@drawable/level_list_button_checkable"
            android:text="Button" />
    
    </RelativeLayout>
    LevelListActivity.java:
    package com.hualu.animation.levellist;
    
    import com.hualu.animation.R;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    
    public class LevelListActivity extends Activity {
    
    	
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.layout_level_list) ;
    		final	Button b = (Button)this.findViewById(R.id.button1) ;
    		b.setOnClickListener(new View.OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				System.out.println("level change"+b.getBackground().getLevel());
    				
    				b.getBackground().setLevel(1) ;
    			}
    		}) ;
    	}
    }
    

    效果:
    点击前:


    点击后:











  • 相关阅读:
    Ecplilse使用
    JDK安装
    浏览器的前世今生
    RethinkDB
    [css]兼容性
    【js】undefined
    String面试题
    SOS.dll(SOS 调试扩展)
    【ajax跨域】原因原理解决
    腾讯WEB前端开发三轮面试经历及面试题
  • 原文地址:https://www.cnblogs.com/java20130722/p/3207257.html
Copyright © 2020-2023  润新知