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) ;
    			}
    		}) ;
    	}
    }
    

    效果:
    点击前:


    点击后:











  • 相关阅读:
    JavaScript严谨模式(Strict Mode)提升开发效率和质量(转载)
    如何调用.Net中的非Public方法
    ViewState机制由浅入深1
    使用SQL向SQL Server2005中插入图片
    ViewState机制由浅入深3
    在服务器端修改HTML控件的属性
    ViewState机制由浅入深2
    IsPostBack深入探讨
    关于架构的小整理,仅限于个人
    关于文件操作的小方法
  • 原文地址:https://www.cnblogs.com/java20130722/p/3207257.html
Copyright © 2011-2022 走看看