作者:占志杰

原文链接

demo源码地址

  • 最近在学习Android开发,和学习其他任何语言一样,不管理论上学得多扎实,最后都一定要付诸实践,不然很容易忘掉,而且也仅仅停留在皮毛上,记录下自己练手的APP的详细实践过程,方便以后忘了回过头来复习。

  • 这个APP的内容主要包括:APP图标的设置,名称设置,用户界面简单实现,宠物属性值的进度条展示,宠物装备的购买等等。

  • 美中不足的是还没学到数据存储,每次进去都是初始化的数据,只能以后学到了,有时间更新一下。

学习内容:

  • APP图标,名称的设置;

  • intent 在不同Activity之间的跳转与传值
    (startActivityForResult()与onActivityResult()与setResult()参数分析,activity带参数的返回);

  • 简单的线性布局;

  • 进度条ProgressBar的使用;

目录表格

目录
1.图标设置
2.设置APP名称
3.用户登录
4.信息显示
5.装备购买
6.颜色素材
扩展: startActivityForResult
扩展: onActivityResult
扩展: setResult

所需环境:Android 8.0 开发工具:Android studio 3.0以及以上版本

1.图标设置

返回目录

  • 用Android Studio 3.0来新建一个项目,命名为 MyTest。 创建好项目之后,打开app/build.gradle文件检查一下,确保targetSdkVersion已经指定到了26或者更高
  • 如下所示:
         apply plugin: 'com.android.application'android {compileSdkVersion 28defaultConfig {applicationId "com.example.MyTest"minSdkVersion 23targetSdkVersion 28versionCode 1versionName "1.0"testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"}
  • 我在创建新项目的时候默认targetSdkVersion就是28,如果你是低于26的话,手动把它改成26就可以了。
  • 接下来打开AndroidManifest.xml文件,代码如下所示:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.example.myandroidtest1"><applicationandroid:allowBackup="true"android:icon="@drawable/head"android:label="@string/app_name"android:roundIcon="@drawable/background2"android:supportsRtl="true"android:theme="@style/AppTheme"><activity android:name=".For_Study"></activity><activity android:name=".Shop_Device"></activity><activity android:name=".Show_Message"></activity><activity android:name=".User_Regist">            </activity><activity android:name=".MainActivity"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity></application></manifest>
  • 我们重点看android:icon这个属性,通过这个属性,我们将应用的图标指定为了mipmap目录下的ic_launcher文件。
  • 另外android:roundIcon属性,这是一个只适用在Android 7.1系统上的过渡版本,我们不用去管它。
  • 我们需要关注的是mipmap-anydpi-v26这个目录,因为Android 8.0或以上系统的手机,都会使用这个目录下的ic_launcher来作为图标。
  • mipmap-anydpi-v26目录下的ic_launcher是一个XML文件,打开这个文件,
  • 代码如下所示:
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"><background android:drawable="@color/ic_launcher_background"/><foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
  • 在 adaptive-icon 标签中
  • 定义一个标签用于指定图标的背景层,我们可以指定使用普通的PNG、JPG等格式的图片,或者直接指定一个背景色。
  • 定义一个标签用于指定图标的前景层,作为APP的Logo,可以使用PNG、JPG等格式的图片
  • 接下来开始更改图标:选中我们需要更改的工程,然后new -->Image Asset
  • 如下图:

  • 进入页面可以看到
  • Foreground Layer 是选择设置前景
  • Background Layer 是选择设置背景
  • 很多情况下,我们都是使用自己的图标,而非系统自带的,我们只需要选中Image单选框即可选择自己的图标,背景可以自己指定颜色或者图片。
    注意:Name输入框内的名称不要更改,否则会更改失败,选择好后,点击Next

  • 图标的名字红色警告,大家不用在意,直接点击Finish就行了
  • 打开mipmap-anydpi-v26目录下的ic_launcher的图标展示已经是更改后的图片
  • 至此,我们已经完成了APP的图标修改
    -效果如图:

2.设置APP名称

返回目录

  • 到res文件夹下面的values文件夹下修改String.xml文件


  • 修改成自己想要的名字就行了

3.用户登录

返回目录

  • 新建一个布局Layout 命名为: activity_user_login.xml

  • 为登录按钮 设置监听事件,一旦点击就调用passData()

  • 利用 intent 来进行 进行Activity之间的跳转与数据传值的

  • 扩展:

  • startActivityForResult(Intent intent, int requestCode);

    第一个参数:一个Intent对象,用于携带将跳转至下一个界面中使用的数据,使用putExtra(A,B)方法,此处存储的数据类型特别多,基本类型全部支持。

    第二个参数:如果> = 0,当Activity结束时requestCode将归还在onActivityResult()中。以便确定返回的数据是从哪个Activity中返回,用来标识目标activity。

    与下面的resultCode功能一致,感觉Android就是为了保证数据的严格一致性特地设置了两把锁,来保证数据的发送,目的地的严格一致性。

  • 代码如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".User_Login"android:background="@drawable/backgroung"><ImageViewandroid:layout_width="120dp"android:layout_height="150dp"android:id="@+id/iv_head"android:layout_centerHorizontal="true"android:layout_marginTop="80dp"android:layout_marginBottom="50dp"android:src="@drawable/head"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/layout"android:layout_below="@+id/iv_head"android:layout_margin="10dp"android:orientation="vertical"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/register_username"android:layout_margin="5dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/tv_name"android:layout_centerVertical="true"android:text="用户名:"android:textSize="20sp"/><EditTextandroid:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/et_name"android:layout_marginLeft="5dp"android:layout_toRightOf="@+id/tv_name"android:hint="请输入用户名"android:textSize="16sp"/></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/register_password"android:layout_margin="5dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/tv_psw"android:layout_centerVertical="true"android:text="密 码:"android:textSize="20sp"/><EditTextandroid:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/et_password"android:layout_marginLeft="5dp"android:layout_toRightOf="@+id/tv_psw"android:hint="请输入密码"android:inputType="textPassword"android:textSize="16sp"/></RelativeLayout></LinearLayout><Buttonandroid:layout_width="160dp"android:layout_height="48dp"android:id="@+id/btn_send"android:layout_below="@id/layout"android:layout_centerHorizontal="true"android:layout_marginLeft="10dp"android:layout_marginRight="10dp"android:text="登 录"android:background="@color/darkorchid"android:textColor="@color/gold"android:textSize="20sp"android:textStyle="bold"/>
</RelativeLayout>
  • 对应着,新建一个Activity,命名为: User_Login

  • 监听登录按钮

  • 获取用户名,密码的数据,并用 intent 跳转Activity和传值

  • 扩展: startActivityForResult
  • 返回目录

  • startActivityForResult(Intent intent, int requestCode);
    第一个参数:一个Intent对象,用于携带将跳转至下一个界面中使用的数据,使用putExtra(A,B)方法,此处存储的数据类型特别多,基本类型全部支持。

    第二个参数:如果 requestCode > = 0,当Activity结束时requestCode将归还在onActivityResult()中。以便确定返回的数据是从哪个Activity中返回,用来标识目标activity。

  • 代码如下:

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;public class User_Login extends AppCompatActivity {private EditText et_password;private Button btn_send;private EditText et_name;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_user_login);et_name = (EditText)findViewById(R.id.et_name);et_password = (EditText)findViewById(R.id.et_password);btn_send = (Button)findViewById(R.id.btn_send);btn_send.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {passData();}});}public void passData(){Intent intent=new Intent(this,Show_Message.class);intent.putExtra("name",et_name.getText().toString().trim());intent.putExtra("password",et_password.getText().toString().trim());startActivity(intent);}
}

效果如图:

4.信息显示

返回目录

  • 新建一个布局Layout 命名为: activity_show_message.xml
  • 内容有:用户登录信息展示,进度条展示各种属性,还有跳转商店页面的按钮
  • 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"android:background="@drawable/backgroung"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginBottom="5dp"android:layout_marginTop="10dp"android:orientation="horizontal"android:padding="15dp"><ImageViewandroid:layout_width="0dp"android:layout_height="150dp"android:layout_weight="1"android:id="@+id/pet_imgv"android:background="@drawable/pet"/><LinearLayoutandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_weight="1"android:orientation="vertical"android:paddingLeft="20dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="用户名:"android:textSize="14sp"android:id="@+id/u_name"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="密 码:"android:textSize="14sp"android:id="@+id/u_password"/></LinearLayout>
</LinearLayout><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/pet_dialog_tv"android:layout_gravity="center"android:layout_marginBottom="25dp"android:text="快给宠物购买装备,学习技能吧!"android:textSize="20sp"/><TableLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_marginBottom="10dp"android:layout_marginLeft="20dp"android:layout_marginRight="5dp"><TableRowandroid:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:text="生命值:"android:textColor="@color/lightgoldenrodyellow"android:textSize="18sp"/><ProgressBarandroid:id="@+id/progressBar1"style="?android:attr/progressBarStyleHorizontal"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_weight="2"/><TextViewandroid:id="@+id/tv_life_progress"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:layout_gravity="center"android:text="0"android:textColor="#000000"android:textSize="18sp"/></TableRow><TableRowandroid:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:text="攻击力:"android:textColor="@color/lightgoldenrodyellow"android:textSize="18sp"/><ProgressBarandroid:id="@+id/progressBar2"style="?android:attr/progressBarStyleHorizontal"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_weight="2"/><TextViewandroid:id="@+id/tv_attack_progress"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:layout_gravity="center"android:text="0"android:textColor="#000000"android:textSize="18sp"/></TableRow><TableRowandroid:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:text="敏 捷:"android:textColor="@color/lightgoldenrodyellow"android:textSize="18sp"/><ProgressBarandroid:id="@+id/progressBar3"style="?android:attr/progressBarStyleHorizontal"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_weight="2"/><TextViewandroid:id="@+id/tv_speed_progress"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:layout_gravity="center"android:text="0"android:textColor="#000000"android:textSize="18sp"/></TableRow></TableLayout><Buttonandroid:layout_width="160dp"android:layout_height="48dp"android:id="@+id/btn_baby"android:layout_gravity="center"android:background="@color/gold"android:text="立即购买GO!"android:textColor="@color/violet"android:textSize="18sp"android:onClick="click"android:textStyle="bold"/><TableLayoutandroid:layout_marginTop="10dp"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_marginLeft="20dp"android:layout_marginRight="5dp"><TableRowandroid:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:text="智 力:"android:textColor="@color/darkorchid"android:textSize="18sp"/><ProgressBarandroid:id="@+id/progressBar4"style="?android:attr/progressBarStyleHorizontal"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_weight="2"/><TextViewandroid:id="@+id/tv_brain_progress"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:layout_gravity="center"android:text="0"android:textColor="#000000"android:textSize="18sp"/></TableRow><TableRowandroid:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:text="品 质:"android:textColor="@color/darkorchid"android:textSize="18sp"/><ProgressBarandroid:id="@+id/progressBar5"style="?android:attr/progressBarStyleHorizontal"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_weight="2"/><TextViewandroid:id="@+id/tv_quality_progress"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:layout_gravity="center"android:text="0"android:textColor="#000000"android:textSize="18sp"/></TableRow><TableRowandroid:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:text="能 力:"android:textColor="@color/darkorchid"android:textSize="18sp"/><ProgressBarandroid:id="@+id/progressBar6"style="?android:attr/progressBarStyleHorizontal"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_weight="2"/><TextViewandroid:id="@+id/tv_ability_progress"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:layout_gravity="center"android:text="0"android:textColor="#000000"android:textSize="18sp"/></TableRow></TableLayout><Buttonandroid:layout_marginTop="10dp"android:layout_width="160dp"android:layout_height="48dp"android:id="@+id/btn_study"android:layout_gravity="center"android:background="@color/gold"android:text="学习成长GO!"android:textColor="@color/violet"android:textSize="18sp"android:onClick="click2"android:textStyle="bold"/>
</LinearLayout>
  • 对应着,新建一个Activity,命名为: Show_Message

  • 初始化进度条和文本编辑组件,获取 intent 里面的用户登录信息展示出来,并设置进度条的最大值和置零

  • 对商店购物按钮进行监听,设置 intent

  • 重写onActivityResult()方法,获取从其他Activity跳转回来所带的数据

  • 获取到数据后,对属性进度框进行更新,自定义方法updateProgress()

  • 扩展: onActivityResult
  • 返回目录

  • onActivityResult(int requestCode, int resultCode, Intent data)

    第一个参数:这个整数requestCode用于与startActivityForResult中的requestCode中值进行比较判断,是以便确认返回的数据是从哪个Activity返回的。

    第二个参数:这整数resultCode是由子Activity通过其setResult()方法返回。适用于多个activity都返回数据时,来标识到底是哪一个activity返回的值。

    第三个参数:一个Intent对象,带有返回的数据。可以通过data.getXxxExtra( );方法来获取指定数据类型的数据。

  • 代码如下:


import android.content.Intent;import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;import android.widget.ProgressBar;
import android.widget.TextView;public class Show_Message extends AppCompatActivity {private TextView u_name;private TextView u_password;private ProgressBar mProgressBar1;private ProgressBar mProgressBar2;private ProgressBar mProgressBar3;private TextView mLifeTV;private TextView mAttackTV;private TextView mSpeedTV;private ProgressBar mProgressBar4;private ProgressBar mProgressBar5;private ProgressBar mProgressBar6;private TextView mBrainTV;private TextView mQualityTV;private TextView mAbilityTV;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_show_message);Intent intent = getIntent();String name = intent.getStringExtra("name");String password = intent.getStringExtra("password");u_name = (TextView)findViewById(R.id.u_name);u_password = (TextView)findViewById(R.id.u_password);u_name.setText("用 户:"+name);u_password.setText("密 码:"+password);mLifeTV = (TextView)findViewById(R.id.tv_life_progress);mAttackTV = (TextView)findViewById(R.id.tv_attack_progress);mSpeedTV = (TextView)findViewById(R.id.tv_speed_progress);mBrainTV = (TextView)findViewById(R.id.tv_brain_progress);mQualityTV = (TextView)findViewById(R.id.tv_quality_progress);mAbilityTV = (TextView)findViewById(R.id.tv_ability_progress);initProgress();}private void initProgress(){mProgressBar1 = (ProgressBar)findViewById(R.id.progressBar1);mProgressBar2 = (ProgressBar)findViewById(R.id.progressBar2);mProgressBar3 = (ProgressBar)findViewById(R.id.progressBar3);mProgressBar1.setMax(1000);mProgressBar2.setMax(1000);mProgressBar3.setMax(1000);mProgressBar4 = (ProgressBar)findViewById(R.id.progressBar4);mProgressBar4.setMax(100);mProgressBar5 = (ProgressBar)findViewById(R.id.progressBar5);mProgressBar5.setMax(100);mProgressBar6 = (ProgressBar)findViewById(R.id.progressBar6);mProgressBar6.setMax(100);}public void click(View view){Intent intent = new Intent(this,Shop_Device.class);startActivityForResult(intent,1);}public void click2(View view){Intent intent2 = new Intent(this,For_Study.class);startActivityForResult(intent2,1);}@Overrideprotected void onActivityResult(int requestCode,int resultCode,Intent data){super.onActivityResult(requestCode,resultCode,data);if(data!=null){if(requestCode==1){if(resultCode==1){ItemInfo info = (ItemInfo)data.getSerializableExtra("equipment");updateProgress(info);}else{Subject study = (Subject)data.getSerializableExtra("study");updateProgress2(study);}}}}private void updateProgress2(Subject study){int progress4 = mProgressBar4.getProgress();mProgressBar4.setProgress(progress4+study.getBrain());mBrainTV.setText(mProgressBar4.getProgress()+"");int progress5 = mProgressBar5.getProgress();mProgressBar5.setProgress(progress5+study.getQuality());mQualityTV.setText(mProgressBar5.getProgress()+"");int progress6 = mProgressBar6.getProgress();mProgressBar6.setProgress(progress6+study.getAbility());mAbilityTV.setText(mProgressBar6.getProgress()+"");}private void updateProgress(ItemInfo info){int progress1 = mProgressBar1.getProgress();int progress2 = mProgressBar2.getProgress();int progress3 = mProgressBar3.getProgress();mProgressBar1.setProgress(progress1+info.getLife());mProgressBar2.setProgress(progress2+info.getAcctack());mProgressBar3.setProgress(progress3+info.getSpeed());mLifeTV.setText(mProgressBar1.getProgress()+"");mAttackTV.setText(mProgressBar2.getProgress()+"");mSpeedTV.setText(mProgressBar3.getProgress()+"");}
}
  • 效果如图:

5.装备购买

返回目录

  • 为装备添加一个item类,存放装备的各种属性:ItemInfo

  • 属性有名称,攻击属性,生命属性,速度属性,赋予get和set方法,并序列化

  • 代码如下:

import java.io.Serializable;public class ItemInfo implements Serializable {private String name;private int acctack;private int life;private int speed;public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAcctack() {return acctack;}public void setAcctack(int acctack) {this.acctack = acctack;}public int getLife() {return life;}public void setLife(int life) {this.life = life;}public int getSpeed() {return speed;}public void setSpeed(int speed) {this.speed = speed;}public ItemInfo(String name, int acctack, int life, int spped){this.name = name;this.acctack = acctack;this.life = life;this.speed = spped;}}
  • 新建一个布局Layout 命名为: activity_shop_device.xml
  • 内容有:装备属性界面展示
  • 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/backgroung"android:orientation="vertical"><LinearLayoutandroid:id="@+id/rl"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="#307f7f7f"android:gravity="center_vertical"android:orientation="horizontal"android:padding="5dp"><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:background="@drawable/sword_icon" /><TextViewandroid:id="@+id/tv_name"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="商品名称" /><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="40dp"android:orientation="vertical"><TextViewandroid:id="@+id/tv_life"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="生命值"android:textSize="13sp" /><TextViewandroid:id="@+id/tv_attack"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="攻击力"android:textSize="13sp" /><TextViewandroid:id="@+id/tv_speed"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="速度"android:textSize="13sp" /></LinearLayout></LinearLayout><LinearLayoutandroid:id="@+id/bmw"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="#307f7f7f"android:gravity="center_vertical"android:orientation="horizontal"android:layout_marginTop="20dp"android:padding="5dp"><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:background="@drawable/bmw_icon" /><TextViewandroid:id="@+id/tv_name2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="商品名称" /><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/bmw"android:layout_marginLeft="40dp"android:orientation="vertical"><TextViewandroid:id="@+id/tv_life2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="生命值"android:textSize="13sp" /><TextViewandroid:id="@+id/tv_attack2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="攻击力"android:textSize="13sp" /><TextViewandroid:id="@+id/tv_speed2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="速度"android:textSize="13sp" /></LinearLayout></LinearLayout><LinearLayoutandroid:id="@+id/girl"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="#307f7f7f"android:gravity="center_vertical"android:orientation="horizontal"android:layout_marginTop="20dp"android:padding="5dp"><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:background="@drawable/girl_icon" /><TextViewandroid:id="@+id/tv_name3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="商品名称" /><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/girl"android:layout_marginLeft="40dp"android:orientation="vertical"><TextViewandroid:id="@+id/tv_life3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="生命值"android:textSize="13sp" /><TextViewandroid:id="@+id/tv_attack3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="攻击力"android:textSize="13sp" /><TextViewandroid:id="@+id/tv_speed3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="速度"android:textSize="13sp" /></LinearLayout></LinearLayout></LinearLayout>
  • 对应着,新建一个Activity,命名为: Shop_Device

  • 初始化装备属性,并展示到界面上

  • 为每个item的LinearLayout设置点击监听事件

  • 获取被点击的装备数据,重写setResult(),将数据存入 intent ,并跳转回原展示界面

  • 扩展: setResult
  • 返回目录

  • setResult(int resultCode, Intent data)

    在意图跳转的目的地界面调用这个方法把Activity想要返回的数据返回到主Activity,

    第一个参数:当Activity结束时resultCode将归还在onActivityResult()中,一般为RESULT_CANCELED , RESULT_OK该值默认为-1。

    第二个参数:一个Intent对象,返回给主Activity的数据。在intent对象携带了要返回的数据,使用putExtra( )方法。

  • 代码如下:

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;public class Shop_Device extends AppCompatActivity implements View.OnClickListener {private ItemInfo itemInfo;private ItemInfo itemInfo2;private ItemInfo itemInfo3;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_shop_device);// 初始化 装备属性itemInfo = new ItemInfo("金剑",100,20,20);itemInfo2 = new ItemInfo("宝马",50,10,180);itemInfo3 = new ItemInfo("小侍女",20,50,30);// 设置点击监听findViewById(R.id.rl).setOnClickListener(this);// 获取界面元素TextView mLifeTV = (TextView)findViewById(R.id.tv_life);TextView mNameTV = (TextView)findViewById(R.id.tv_name);TextView mAttackTV = (TextView)findViewById(R.id.tv_attack);TextView mSpeedTV = (TextView)findViewById(R.id.tv_speed);// 界面设值mLifeTV.setText("生命值+"+itemInfo.getLife());mNameTV.setText(itemInfo.getName()+" ");mSpeedTV.setText("敏捷度+"+itemInfo.getSpeed());mAttackTV.setText("攻击力+"+itemInfo.getAcctack());// 设置点击监听findViewById(R.id.bmw).setOnClickListener(this);TextView mLifeTV2 = (TextView)findViewById(R.id.tv_life2);TextView mNameTV2 = (TextView)findViewById(R.id.tv_name2);TextView mAttackTV2 = (TextView)findViewById(R.id.tv_attack2);TextView mSpeedTV2 = (TextView)findViewById(R.id.tv_speed2);mLifeTV2.setText("生命值+"+itemInfo2.getLife());mNameTV2.setText(itemInfo2.getName()+" ");mSpeedTV2.setText("敏捷度+"+itemInfo2.getSpeed());mAttackTV2.setText("攻击力+"+itemInfo2.getAcctack());// 设置点击监听findViewById(R.id.girl).setOnClickListener(this);TextView mLifeTV3 = (TextView)findViewById(R.id.tv_life3);TextView mNameTV3 = (TextView)findViewById(R.id.tv_name3);TextView mAttackTV3 = (TextView)findViewById(R.id.tv_attack3);TextView mSpeedTV3 = (TextView)findViewById(R.id.tv_speed3);mLifeTV3.setText("生命值+"+itemInfo3.getLife());mNameTV3.setText(itemInfo3.getName()+" ");mSpeedTV3.setText("敏捷度+"+itemInfo3.getSpeed());mAttackTV3.setText("攻击力+"+itemInfo3.getAcctack());}@Overridepublic void onClick(View v) {// 获取intentIntent intent = new Intent();switch (v.getId()){case R.id.rl:// 存放序列化后的装备对象intent.putExtra("equipment",itemInfo);// 返回结果码和intentsetResult(1,intent);// 关闭该界面finish();// 退出选择break;case R.id.bmw:// 存放序列化后的装备对象intent.putExtra("equipment",itemInfo2);// 返回结果码和intentsetResult(1,intent);// 关闭该界面finish();// 退出选择break;case R.id.girl:// 存放序列化后的装备对象intent.putExtra("equipment",itemInfo3);// 返回结果码和intentsetResult(1,intent);// 关闭该界面finish();// 退出选择break;}}
}
  • 效果如图:
  • 点击选择对应装备后,回返回用户信息展示界面,并更新属性数据
  • 效果如图:
  • 附上下面那块,学习技能的代码:
  • 新建Layout:activity_for_study.xml
  • 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/backgroung"android:orientation="vertical"><LinearLayoutandroid:id="@+id/english"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="#307f7f7f"android:gravity="center_vertical"android:orientation="horizontal"android:padding="5dp"><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:background="@drawable/english_icon" /><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="40dp"android:orientation="vertical"><TextViewandroid:id="@+id/st_name"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="科目名称" /><TextViewandroid:id="@+id/st_content"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="科目内容" /></LinearLayout><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="40dp"android:orientation="vertical"><TextViewandroid:id="@+id/tv_brain"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="智力"android:textSize="13sp" /><TextViewandroid:id="@+id/tv_quality"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="品质"android:textSize="13sp" /><TextViewandroid:id="@+id/tv_ability"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="能力"android:textSize="13sp" /></LinearLayout></LinearLayout><LinearLayoutandroid:id="@+id/math"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="#307f7f7f"android:gravity="center_vertical"android:orientation="horizontal"android:layout_marginTop="20dp"android:padding="5dp"><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:background="@drawable/math_icon" /><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="40dp"android:orientation="vertical"><TextViewandroid:id="@+id/st_name2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="科目名称" /><TextViewandroid:id="@+id/st_content2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="科目内容" /></LinearLayout><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/bmw"android:layout_marginLeft="40dp"android:orientation="vertical"><TextViewandroid:id="@+id/tv_brain2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="智力"android:textSize="13sp" /><TextViewandroid:id="@+id/tv_quality2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="品质"android:textSize="13sp" /><TextViewandroid:id="@+id/tv_ability2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="能力"android:textSize="13sp" /></LinearLayout></LinearLayout><LinearLayoutandroid:id="@+id/china"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="#307f7f7f"android:gravity="center_vertical"android:orientation="horizontal"android:layout_marginTop="20dp"android:padding="5dp"><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:background="@drawable/china_icon" /><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="40dp"android:orientation="vertical"><TextViewandroid:id="@+id/st_name3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="科目名称" /><TextViewandroid:id="@+id/st_content3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="科目内容" /></LinearLayout><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/girl"android:layout_marginLeft="40dp"android:orientation="vertical"><TextViewandroid:id="@+id/tv_brain3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="智力"android:textSize="13sp" /><TextViewandroid:id="@+id/tv_quality3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="品质"android:textSize="13sp" /><TextViewandroid:id="@+id/tv_ability3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="能力"android:textSize="13sp" /></LinearLayout></LinearLayout><LinearLayoutandroid:id="@+id/politics"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="#307f7f7f"android:gravity="center_vertical"android:orientation="horizontal"android:layout_marginTop="20dp"android:padding="5dp"><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:background="@drawable/politics_icon" /><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="40dp"android:orientation="vertical"><TextViewandroid:id="@+id/st_name4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="科目名称" /><TextViewandroid:id="@+id/st_content4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:text="科目内容" /></LinearLayout><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/girl"android:layout_marginLeft="40dp"android:orientation="vertical"><TextViewandroid:id="@+id/tv_brain4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="智力"android:textSize="13sp" /><TextViewandroid:id="@+id/tv_quality4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="品质"android:textSize="13sp" /><TextViewandroid:id="@+id/tv_ability4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="能力"android:textSize="13sp" /></LinearLayout></LinearLayout></LinearLayout>
  • 新建学科类:Subject
  • 代码如下:
import java.io.Serializable;public class Subject implements Serializable {private String name;private String content;private int brain;private int quality;private int ability;public Subject(String name, String content, int brain, int quality, int ability) {this.name = name;this.content = content;this.brain = brain;this.quality = quality;this.ability = ability;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getContent() {return content;}public void setContent(String content) {this.content = content;}public int getBrain() {return brain;}public void setBrain(int brain) {this.brain = brain;}public int getQuality() {return quality;}public void setQuality(int quality) {this.quality = quality;}public int getAbility() {return ability;}public void setAbility(int ability) {this.ability = ability;}
}
  • 新建Activity:For_Study
  • 代码如下:
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;public class For_Study extends AppCompatActivity implements View.OnClickListener{private Subject study;private Subject study2;private Subject study3;private Subject study4;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_for_study);// 初始化 科目study = new Subject("英语","每天学十个单词",2,3,5);study2 = new Subject("数学","每天学一个小节",5,2,5);study3 = new Subject("语文","每天背一首古诗",1,4,5);study4 = new Subject("政治","每天背一个小节",3,3,5);// 设置点击监听TextView mNameTV = (TextView)findViewById(R.id.st_name);TextView mContentTV = (TextView)findViewById(R.id.st_content);findViewById(R.id.english).setOnClickListener(this);TextView mBrainTV = (TextView)findViewById(R.id.tv_brain);TextView mQualityTV = (TextView)findViewById(R.id.tv_quality);TextView mAbilityTV = (TextView)findViewById(R.id.tv_ability);mNameTV.setText(study.getName()+" ");mContentTV.setText(study.getContent());mBrainTV.setText("智 力+"+study.getBrain());mQualityTV.setText("品 质+"+study.getQuality());mAbilityTV.setText("能 力+"+study.getAbility());// 设置点击监听TextView mName2TV = (TextView)findViewById(R.id.st_name2);TextView mContent2TV = (TextView)findViewById(R.id.st_content2);findViewById(R.id.math).setOnClickListener(this);TextView mBrain2TV = (TextView)findViewById(R.id.tv_brain2);TextView mQuality2TV = (TextView)findViewById(R.id.tv_quality2);TextView mAbility2TV = (TextView)findViewById(R.id.tv_ability2);mName2TV.setText(study2.getName()+" ");mContent2TV.setText(study2.getContent());mBrain2TV.setText("智 力+"+study2.getBrain());mQuality2TV.setText("品 质+"+study2.getQuality());mAbility2TV.setText("能 力+"+study2.getAbility());// 设置点击监听TextView mName3TV = (TextView)findViewById(R.id.st_name3);TextView mContent3TV = (TextView)findViewById(R.id.st_content3);findViewById(R.id.china).setOnClickListener(this);TextView mBrain3TV = (TextView)findViewById(R.id.tv_brain3);TextView mQuality3TV = (TextView)findViewById(R.id.tv_quality3);TextView mAbility3TV = (TextView)findViewById(R.id.tv_ability3);mName3TV.setText(study3.getName()+" ");mContent3TV.setText(study3.getContent());mBrain3TV.setText("智 力+"+study3.getBrain());mQuality3TV.setText("品 质+"+study3.getQuality());mAbility3TV.setText("能 力+"+study3.getAbility());// 设置点击监听TextView mName4TV = (TextView)findViewById(R.id.st_name4);TextView mContent4TV = (TextView)findViewById(R.id.st_content4);findViewById(R.id.politics).setOnClickListener(this);TextView mBrain4TV = (TextView)findViewById(R.id.tv_brain4);TextView mQuality4TV = (TextView)findViewById(R.id.tv_quality4);TextView mAbility4TV = (TextView)findViewById(R.id.tv_ability4);mName4TV.setText(study4.getName()+" ");mContent4TV.setText(study4.getContent());mBrain4TV.setText("智 力+"+study4.getBrain());mQuality4TV.setText("品 质+"+study4.getQuality());mAbility4TV.setText("能 力+"+study4.getAbility());}@Overridepublic void onClick(View v) {// 获取intentIntent intent = new Intent();switch (v.getId()){case R.id.english:// 存放序列化后的装备对象intent.putExtra("study",study);// 返回结果码和intentsetResult(2,intent);// 关闭该界面finish();// 退出选择break;case R.id.math:// 存放序列化后的装备对象intent.putExtra("study",study2);// 返回结果码和intentsetResult(2,intent);// 关闭该界面finish();// 退出选择break;case R.id.china:// 存放序列化后的装备对象intent.putExtra("study",study3);// 返回结果码和intentsetResult(2,intent);// 关闭该界面finish();// 退出选择break;case R.id.politics:// 存放序列化后的装备对象intent.putExtra("study",study4);// 返回结果码和intentsetResult(2,intent);// 关闭该界面finish();// 退出选择break;}}}
  • 效果如图:

完成啦!以上就是练手APP的全部内容,至于图片素材什么的,都可以自行查找,这里就不提供了。

6.颜色素材

返回目录

  • 另外如果新建项目的话,很多颜色属性素材都是需要引入的,这里提供一个比较完整的颜色素材,只要把它放到res下values文件夹里面的colors.xml
    就可以引用啦。

  • 代码如下:
<?xml version="1.0" encoding="utf-8" ?>
<resources><color name="colorPrimary">#008577</color><color name="colorPrimaryDark">#00574B</color><color name="colorAccent">#D81B60</color><color name="white">#ffffff</color><!--白色 --><color name="ivory">#fffff0</color><!--象牙色 --><color name="lightyellow">#ffffe0</color><!--亮黄色 --><color name="yellow">#ffff00</color><!--黄色 --><color name="snow">#fffafa</color><!--雪白色 --><color name="floralwhite">#fffaf0</color><!--花白色 --><color name="lemonchiffon">#fffacd</color><!--柠檬绸色 --><color name="cornsilk">#fff8dc</color><!--米绸色 --><color name="seaShell">#fff5ee</color><!--海贝色 --><color name="lavenderblush">#fff0f5</color><!--淡紫红 --><color name="papayawhip">#ffefd5</color><!--番木色 --><color name="blanchedalmond">#ffebcd</color><!--白杏色 --><color name="mistyrose">#ffe4e1</color><!--浅玫瑰色 --><color name="bisque">#ffe4c4</color><!--桔黄色 --><color name="moccasin">#ffe4b5</color><!--鹿皮色 --><color name="navajowhite">#ffdead</color><!--纳瓦白 --><color name="peachpuff">#ffdab9</color><!--桃色 --><color name="gold">#ffd700</color><!--金色 --><color name="pink">#ffc0cb</color><!--粉红色 --><color name="lightpink">#ffb6c1</color><!--亮粉红色 --><color name="orange">#ffa500</color><!--橙色 --><color name="lightsalmon">#ffa07a</color><!--亮肉色 --><color name="darkorange">#ff8c00</color><!--暗桔黄色 --><color name="coral">#ff7f50</color><!--珊瑚色 --><color name="hotpink">#ff69b4</color><!--热粉红色 --><color name="tomato">#ff6347</color><!--西红柿色 --><color name="orangered">#ff4500</color><!--红橙色 --><color name="deeppink">#ff1493</color><!--深粉红色 --><color name="fuchsia">#ff00ff</color><!--紫红色 --><color name="magenta">#ff00ff</color><!--红紫色 --><color name="red">#ff0000</color><!--红色 --><color name="oldlace">#fdf5e6</color><!--老花色 --><color name="lightgoldenrodyellow">#fafad2</color><!--亮金黄色 --><color name="linen">#faf0e6</color><!--亚麻色 --><color name="antiquewhite">#faebd7</color><!--古董白 --><color name="salmon">#fa8072</color><!--鲜肉色 --><color name="ghostwhite">#f8f8ff</color><!--幽灵白 --><color name="mintcream">#f5fffa</color><!--薄荷色 --><color name="whitesmoke">#f5f5f5</color><!--烟白色 --><color name="beige">#f5f5dc</color><!--米色 --><color name="wheat">#f5deb3</color><!--浅黄色 --><color name="sandybrown">#f4a460</color><!--沙褐色 --><color name="azure">#f0ffff</color><!--天蓝色 --><color name="honeydew">#f0fff0</color><!--蜜色 --><color name="aliceblue">#f0f8ff</color><!--艾利斯兰 --><color name="khaki">#f0e68c</color><!--黄褐色 --><color name="lightcoral">#f08080</color><!--亮珊瑚色 --><color name="palegoldenrod">#eee8aa</color><!--苍麒麟色 --><color name="violet">#ee82ee</color><!--紫罗兰色 --><color name="darksalmon">#e9967a</color><!--暗肉色 --><color name="lavender">#e6e6fa</color><!--淡紫色 --><color name="lightcyan">#e0ffff</color><!--亮青色 --><color name="burlywood">#deb887</color><!--实木色 --><color name="plum">#dda0dd</color><!--洋李色 --><color name="gainsboro">#dcdcdc</color><!--淡灰色 --><color name="crimson">#dc143c</color><!--暗深红色 --><color name="palevioletred">#db7093</color><!--苍紫罗兰色 --><color name="goldenrod">#daa520</color><!--金麒麟色 --><color name="orchid">#da70d6</color><!--淡紫色 --><color name="thistle">#d8bfd8</color><!--蓟色 --><color name="lightgray">#d3d3d3</color><!--亮灰色 --><color name="lightgrey">#d3d3d3</color><!--亮灰色 --><color name="tan">#d2b48c</color><!--茶色 --><color name="chocolate">#d2691e</color><!--巧可力色 --><color name="peru">#cd853f</color><!--秘鲁色 --><color name="indianred">#cd5c5c</color><!--印第安红 --><color name="mediumvioletred">#c71585</color><!--中紫罗兰色 --><color name="silver">#c0c0c0</color><!--银色 --><color name="darkkhaki">#bdb76b</color><!--暗黄褐色 --><color name="rosybrown">#bc8f8f</color><!--褐玫瑰红 --><color name="mediumorchid">#ba55d3</color><!--中粉紫色 --><color name="darkgoldenrod">#b8860b</color><!--暗金黄色 --><color name="firebrick">#b22222</color><!--火砖色 --><color name="powderblue">#b0e0e6</color><!--粉蓝色 --><color name="lightsteelblue">#b0c4de</color><!--亮钢兰色 --><color name="paleturquoise">#afeeee</color><!--苍宝石绿 --><color name="greenyellow">#adff2f</color><!--黄绿色 --><color name="lightblue">#add8e6</color><!--亮蓝色 --><color name="darkgray">#a9a9a9</color><!--暗灰色 --><color name="darkgrey">#a9a9a9</color><!--暗灰色 --><color name="brown">#a52a2a</color><!--褐色 --><color name="sienna">#a0522d</color><!--赭色 --><color name="darkorchid">#9932cc</color><!--暗紫色 --><color name="palegreen">#98fb98</color><!--苍绿色 --><color name="darkviolet">#9400d3</color><!--暗紫罗兰色 --><color name="mediumpurple">#9370db</color><!--中紫色 --><color name="lightgreen">#90ee90</color><!--亮绿色 --><color name="darkseagreen">#8fbc8f</color><!--暗海兰色 --><color name="saddlebrown">#8b4513</color><!--重褐色 --><color name="darkmagenta">#8b008b</color><!--暗洋红 --><color name="darkred">#8b0000</color><!--暗红色 --><color name="blueviolet">#8a2be2</color><!--紫罗兰蓝色 --><color name="lightskyblue">#87cefa</color><!--亮天蓝色 --><color name="skyblue">#87ceeb</color><!--天蓝色 --><color name="gray">#808080</color><!--灰色 --><color name="grey">#808080</color><!--灰色 --><color name="olive">#808000</color><!--橄榄色 --><color name="purple">#800080</color><!--紫色 --><color name="maroon">#800000</color><!--粟色 --><color name="aquamarine">#7fffd4</color><!--碧绿色 --><color name="chartreuse">#7fff00</color><!--黄绿色 --><color name="lawngreen">#7cfc00</color><!--草绿色 --><color name="mediumslateblue">#7b68ee</color><!--中暗蓝色 --><color name="lightslategray">#778899</color><!--亮蓝灰 --><color name="lightslategrey">#778899</color><!--亮蓝灰 --><color name="slategray">#708090</color><!--灰石色 --><color name="slategrey">#708090</color><!--灰石色 --><color name="olivedrab">#6b8e23</color><!--深绿褐色 --><color name="slateblue">#6a5acd</color><!--石蓝色 --><color name="dimgray">#696969</color><!--暗灰色 --><color name="dimgrey">#696969</color><!--暗灰色 --><color name="mediumaquamarine">#66cdaa</color><!--中绿色 --><color name="cornflowerblue">#6495ed</color><!--菊兰色 --><color name="cadetblue">#5f9ea0</color><!--军兰色 --><color name="darkolivegreen">#556b2f</color><!--暗橄榄绿 --><color name="indigo">#4b0082</color><!--靛青色 --><color name="mediumturquoise">#48d1cc</color><!--中绿宝石 --><color name="darkslateblue">#483d8b</color><!--暗灰蓝色 --><color name="steelblue">#4682b4</color><!--钢兰色 --><color name="royalblue">#4169e1</color><!--皇家蓝 --><color name="turquoise">#40e0d0</color><!--青绿色 --><color name="mediumseagreen">#3cb371</color><!--中海蓝 --><color name="limegreen">#32cd32</color><!--橙绿色 --><color name="darkslategray">#2f4f4f</color><!--暗瓦灰色 --><color name="darkslategrey">#2f4f4f</color><!--暗瓦灰色 --><color name="seagreen">#2e8b57</color><!--海绿色 --><color name="forestgreen">#228b22</color><!--森林绿 --><color name="lightseagreen">#20b2aa</color><!--亮海蓝色 --><color name="dodgerblue">#1e90ff</color><!--闪兰色 --><color name="midnightblue">#191970</color><!--中灰兰色 --><color name="aqua">#00ffff</color><!--浅绿色 --><color name="cyan">#00ffff</color><!--青色 --><color name="springgreen">#00ff7f</color><!--春绿色 --><color name="lime">#00ff00</color><!--酸橙色 --><color name="mediumspringgreen">#00fa9a</color><!--中春绿色 --><color name="darkturquoise">#00ced1</color><!--暗宝石绿 --><color name="deepskyblue">#00bfff</color><!--深天蓝色 --><color name="darkcyan">#008b8b</color><!--暗青色 --><color name="teal">#008080</color><!--水鸭色 --><color name="green">#008000</color><!--绿色 --><color name="darkgreen">#006400</color><!--暗绿色 --><color name="blue">#0000ff</color><!--蓝色 --><color name="mediumblue">#0000cd</color><!--中兰色 --><color name="darkblue">#00008b</color><!--暗蓝色 --><color name="navy">#000080</color><!--海军色 --><color name="black">#000000</color><!--黑色 -->
</resources>

Android案例:图标名称设置+用户登录界面+宝宝装备与技能选择相关推荐

  1. 【Android】用户登录界面功能实现:登陆跳转、退出

    文章目录 用户登录界面功能实现:登陆跳转.退出 ♦ 回顾 ♦ 编写 MainActivity 实现功能 登录功能效果 退出弹框.连续点击返回退出 ♦ 设计 activity_my_tool.xml 展 ...

  2. 简单步骤,使用 Android studio 实现保存 QQ 账号密码,和简易 QQ 用户登录界面

    利用 Android studio 2021 软件输出一个简易用户登录界面,拥有头像并且能够实现对自行输入的账号密码进行保存,文件名为 saveqq,功能实现对账号与密码的输入和存储,简单QQ界面布局 ...

  3. android studio 微信登录界面,如何使用Android Studio开发用户登录界面

    满意答案 zhou9081 2016.05.21 采纳率:51%    等级:7 已帮助:411人 如何使用Android Studio开发用户登录界面,具体解决方案如下: 解决方案1: <:t ...

  4. JAVA——创建用户登录界面

    创建用户登录界面 1.新建超市管理系统 File-new-project-java-java project,创建项目名:SupermarketClient. 2.在Supermarket下面创建两个 ...

  5. Bootstrap4+MySQL前后端综合实训-Day06-AM【eclipse详细配置Tomcat、开发web项目、servlet、连接MySQL8.0数据库、用户登录界面的编写与验证、分页查询】

    [Bootstrap4前端框架+MySQL数据库]前后端综合实训[10天课程 博客汇总表 详细笔记][附:实训所有代码] 目   录 eclipse重置视图 MySQL数据库--建数据库.建数据库 s ...

  6. php简单的登录界面,PHP实现简单用户登录界面

    用PHP实现简单的用户登录界面,供大家参考,具体内容如下 首先要实现用户登录界面需要一个html登录表单 用户名: 密码: 重复密码: 然后开始按照流程图写PHP代码 if(trim($_POST[' ...

  7. 用Java实现用户登录界面

    基本步骤 1.创建一个窗体 2.给按钮加上监听 3.获取界面输入框中的值给监听 4.存储用户信息 5.实现登录注册逻辑 1.创建一个窗体 public void LE(){JFrame jf=new ...

  8. [bat] cmd命令进入用户登录界面和屏幕保护程序

    [bat] cmd命令进入用户登录界面和屏幕保护程序 cmd命令进入用户登录界面 rundll32.exe user32.dll,LockWorkStation cmd命令进入屏幕保护程序 C:\Wi ...

  9. 用户登录界面的测试用例

    用户登录界面如何测试 这个界面上有两个输入框,一个提交按钮. 在面试时经常会被问到这道题,考察点是面试者是否熟悉各种测试方法.首先,可以询问面试官用户的需求.例如这个登录界面应该是弹出窗口还是直接在网 ...

最新文章

  1. 计算机视觉与深度学习 | 基于MATLAB的Vibe算法消除鬼影(代码版)
  2. MySQL高级 - SQL技巧 - 数字函数与字符串函数
  3. CodeForces - 617E XOR and Favorite Number(莫队)
  4. SQL约束脚本的用法
  5. 世界范围内糖化血红蛋白报告的3种建议形式
  6. 根据文法画出语法树_输入语法推断的强化学习
  7. 台湾大学生来厦门参访交流
  8. php项目重构,跪求网页重构、前端开发、PHP 开发,坐标深圳腾讯 CDC
  9. IDEA创建maven聚合项目多模块项目并在Tomcat启动图解详细教程
  10. App Shortcuts 快捷方式 Android7 1 的3D Touch
  11. linux下国产达梦数据库的命令行安装
  12. Matlab App Designer 【04】使用公共函数在两个App之间传递数据
  13. 岛屿数量问题(C实现)
  14. 正态分布(近似正态分布)
  15. mix2s适配鸿蒙,小米MIX2S|MIUI10|9.05.12|GPU调节|CPU调节_最新最全的小米MIX 2SROM刷机包下载、刷机...
  16. 音视频最新技术有哪些
  17. 计算机病毒对计算机应用的影响,计算机应用技术对信息化的影响-计算机病毒论文-计算机论文(8页)-原创力文档...
  18. 如何提升数据分析能力,数据分析的正确步骤
  19. 司铭宇讲师:上海某汽车4S店《销售倍增-汽车4S店保险销售技巧提升》培训
  20. 1.初识Abp(模板初始化)

热门文章

  1. 收藏:软考知识点整理|信息系统工程监理与信息系统项目管理基础
  2. 1000亩盐碱地试验田 国稻种芯-田国庆:拓荒精神荒滩变良田
  3. Destoon采集翻译伪原创发布工具
  4. C#在透明窗体WinForm上面画图(电子尺小工具的实现)
  5. mac更换apple id_如何使用Mac在Apple TV上截屏
  6. 第二类边界条件下三维热传导问题求解
  7. 产品工作中的沟通注意事项小总结
  8. 利用阿里云OSS开发一个私人网盘/外链系统,php+js实现
  9. 2019-11-12 kk日记,使用python完成ora2pg的工作小结
  10. AWS S3(对象存储)接口方法