zoukankan      html  css  js  c++  java
  • 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) ;
    			}
    		}) ;
    	}
    }
    

    效果:
    点击前:


    点击后:











  • 相关阅读:
    Vector-Constructors
    C++:多维数组的动态分配(new)和释放(delete)
    C++:多维数组的动态分配(new)和释放(delete)
    COM_利用GetWallpaper()获取墙纸路径
    COM_利用GetWallpaper()获取墙纸路径
    COM 技术相关概念
    COM 技术相关概念
    全排列与next_permutation
    全排列与next_permutation
    屏蔽MFC程序中的ESC键和ENTER键关闭窗口
  • 原文地址:https://www.cnblogs.com/java20130722/p/3207257.html
Copyright © 2011-2022 走看看