安卓app_sl3_25同意游戏条款功能示范


安卓app_sl3_25同意游戏条款功能示范

package com.example.sl3_25;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageButton;
import android.widget.Toast;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final ImageButton imageButton=(ImageButton)findViewById(R.id.start);
        CheckBox checkbox=(CheckBox)findViewById(R.id.checkBox1);
        checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener(){

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                // TODO 自动生成的方法存根
                if(isChecked)
                {
                    imageButton.setVisibility(View.VISIBLE);
                }
                else 
                {
                   imageButton.setVisibility(View.INVISIBLE);
                }
                imageButton.invalidate();//重绘ImageButton
                    
                
            }
            
        });
        imageButton.setOnClickListener(new OnClickListener(){

            @Override
            public void onClick(View v) {
                // TODO 自动生成的方法存根
                Toast.makeText(MainActivity.this, "进入游戏。。。", Toast.LENGTH_SHORT).show();
            }
            
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/background"
    android:gravity="center"    
    tools:context="com.example.sl3_25.MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="20dp"
        style="@style/artclestyle"
        android:text="@string/artcle" />

    <CheckBox
        android:id="@+id/checkBox1"
        android:textSize="22dp"
        android:button="@drawable/check_box"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="我同意" />

    <ImageButton
        android:id="@+id/start"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="invisible"
        android:src="@drawable/button_state" />

<?xml version="1.0" encoding="utf-8"?>



    sl3_25同意游戏条款
    Hello world!
    Settings
             ;温馨提示:本游戏适合各年龄段的玩家,请您合理安排游戏时间,不要沉迷游戏!
    当您连续在线2小时间后,系统将自动结束游戏。如果同意该条款请勾选“我同意”复选框,方可进入游戏。

<?xml version="1.0" encoding="utf-8"?>

<selector
  xmlns:android="http://schemas.android.com/apk/res/android">
    
    
<?xml version="1.0" encoding="utf-8"?>

<selector
  xmlns:android="http://schemas.android.com/apk/res/android">
     
        android:drawable="@drawable/check_f"/>
    
        android:drawable="@drawable/check_t"/>