• 趣拼图最后完成及总结


    趣拼图界面设计如下:

               

    xml代码如下:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/bgc"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/title_background" >

    <TextView
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:gravity="center"
    android:textSize="30sp"
    android:background="@drawable/homepage_titlebg" />
    <LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:gravity="center"
    android:layout_height="60sp">
    <TextView
    android:layout_width="100sp"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:textSize="30sp"
    android:text="@string/yonghuming" />
    <EditText
    android:id="@+id/admin"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:inputType="number"
    android:hint="@string/edit_yhm"
    android:singleLine="true" />
    </LinearLayout>
    <LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="60sp"
    android:gravity="center">
    <TextView
    android:layout_width="100sp"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:textSize="30sp"
    android:text="@string/mima" />
    <EditText
    android:id="@+id/password"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:inputType="textPassword"
    android:hint="@string/edit_mm"
    android:singleLine="true" />
    </LinearLayout>
    <LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="60sp"
    android:gravity="center" >
    <Button
    style="?android:attr/buttonBarButtonStyle"
    android:id="@+id/denglu"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:gravity="center"
    android:textSize="30sp"
    android:text="@string/denglu" />
    <Button
    style="?android:attr/buttonBarButtonStyle"
    android:id="@+id/zhuce"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:gravity="center"
    android:textSize="30sp"
    android:text="@string/zhuce" />
    </LinearLayout>

    </LinearLayout>

    JAVA代码如下:
    package com.example.game;

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.*;
    import android.view.View.OnTouchListener;
    import android.widget.*;
    import android.content.Intent;
    import android.content.res.Resources;
    import android.graphics.Color;
    import android.graphics.drawable.Drawable;

    public class HomepageActivity extends Activity implements View.OnClickListener,OnTouchListener{
    EditText tEdit1,tEdit2;
    Button button_dengLu,button_zhuCe;
    LinearLayout change_bgColor;

    int num_bg;
    String bgimage[] = {
    "#FF0000",
    "#FF4500",
    "#EEEE00",
    "#00FF00",
    "#0000FF",
    "#00EEEE",
    "#CD00CD",
    "#FFFFFF",
    "#CD3700",
    "#8F8F8F"
    };
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.homepage);
    dealWithHomePage();
    }
    public void dealWithHomePage(){
    tEdit1=(EditText)findViewById(R.id.admin);
    tEdit2=(EditText)findViewById(R.id.password);
    button_dengLu=(Button)findViewById(R.id.denglu);
    button_zhuCe=(Button)findViewById(R.id.zhuce);
    button_dengLu.setOnClickListener(this);
    button_zhuCe.setOnClickListener(this);

    change_bgColor = (LinearLayout)findViewById(R.id.bgc);
    change_bgColor.setOnTouchListener(this);

    }

    public void onClick(View view){
    String str1 = tEdit1.getText().toString();
    String str2 = tEdit2.getText().toString();
    if(view==button_dengLu){
    if(str1.equals("123456")&&str2.equals("123456")){
    Intent intent = new Intent(HomepageActivity.this,ChoseGameActivity.class);
    startActivity(intent);
    finish();
    }else{
    Toast.makeText(this,).show();
    }
    }
    }
    public boolean onTouch( View view , MotionEvent event ){
    switch(event.getAction()){
    case MotionEvent.ACTION_UP:
    num_bg++;
    if( num_bg == bgimage.length){
    num_bg = 0;
    }
    change_bgColor.setBackgroundColor(Color.parseColor(bgimage[num_bg]));
    break;
    }
    return true;
    }
    }

    这个项目已经到最后的尾声了,这是一个团队共同努力做出的一个小游戏app,游戏虽小可是却耗费了六个人的心血,虽然弄得也不是特别完善但是我们也认真的去动手操作和认真思考了。
  • 相关阅读:
    Python爬取+BI分析后,微博求助患者的眼泪,全被数据看见了
    BZOJ4321 queue2
    BZOJ4321 queue2
    BZOJ4321 queue2
    Oracle字段根据逗号分割查询数据
    Oracle字段根据逗号分割查询数据
    Oracle字段根据逗号分割查询数据
    Oracle字段根据逗号分割查询数据
    基于Web实现在线绘画拓扑图[GraphEditor]
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
  • 原文地址:https://www.cnblogs.com/chenmanman1502720117/p/6921718.html
Copyright © 2020-2023  润新知