XML1:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" tools:context=".MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="星座预测" android:textSize="30sp" android:textStyle="bold" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="十二星座 即黄道十二宫,是 占星学 描述太阳在天球上经过 黄道 的十二个区域,包括 白羊座 、 金牛座 、 双子座 、 巨蟹座 、 狮子座 、 处女座 、天秤座、 天蝎座 、 人马座 、 摩羯座 、 宝瓶座 、 双鱼座 ,虽然蛇夫座也被黄道经过,但不属占星学所使用的黄道十二宫之列,在占星学的黄道十二宫定义只是指在黄道带上十二个均分的区域,不同于天文学上的黄道星座 。" android:textStyle="bold" android:textColor="#000fff" android:textSize="10sp" android:layout_margin="5dp" /> <Button android:id="@+id/xing" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="星座查询" android:textSize="40sp" android:layout_gravity="center" android:layout_margin="5dp" android:textColor="#000fff" android:textStyle="bold" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="请输入你的姓名" android:textStyle="bold" android:textSize="18sp" android:textColor="#000fff" android:layout_gravity="center" /> <EditText android:layout_width="120dp" android:layout_height="wrap_content" android:layout_margin="5dp" android:textSize="30sp" android:textStyle="bold" android:layout_gravity="center" android:id="@+id/editname"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="请选择你的出生日期" android:textStyle="bold" android:textSize="18sp" android:textColor="#000fff" android:background="#D7a3f5" /> <DatePicker android:id="@+id/date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:textStyle="bold" /> </LinearLayout>
XML2:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity2"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/text" android:text="name" android:textColor="#fff000" android:textSize="20sp" android:layout_margin="50dp" android:textStyle="bold" android:layout_gravity="center" /> <TextView android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/text1" android:text="date" android:textColor="#fff000" android:textSize="20sp" android:layout_margin="50dp" android:textStyle="bold" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/img" android:layout_gravity="center" android:textSize="20sp" android:src="@drawable/ic_launcher_background" android:layout_margin="20dp" /> <ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:id="@+id/text2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="寓意" android:layout_margin="20dp" android:textSize="20sp" android:textStyle="bold" /> </ScrollView> </LinearLayout>
MAINACTIVITY1:
package com.example.myapplicationxingzuo; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.EditText; public class MainActivity extends AppCompatActivity { private Button btn; private EditText editname; private DatePicker date; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btn=findViewById(R.id.xing); editname=findViewById(R.id.editname); date=findViewById(R.id.date); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent=new Intent(MainActivity.this,MainActivity2.class); intent.putExtra("name",editname.getText().toString()); intent.putExtra("year",date.getYear()); intent.putExtra("month",date.getMonth()); intent.putExtra("day",date.getDayOfMonth()); startActivity(intent); } }); } }
MAINACTIVITY2:
package com.example.myapplicationxingzuo; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.text.method.ScrollingMovementMethod; import android.widget.ImageView; import android.widget.TextView; import static java.nio.file.Files.find; public class MainActivity2 extends AppCompatActivity { private ImageView imag_imgzodiac; private TextView text1,text,text2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); text1=findViewById(R.id.text1); text=findViewById(R.id.text); text2=findViewById(R.id.text2); imag_imgzodiac=findViewById(R.id.img); //接收传递过来的值并且显示到相应的文本中 String str1=getIntent().getStringExtra("name"); int year=getIntent().getIntExtra("year",0); int month=getIntent().getIntExtra("month",0); int day=getIntent().getIntExtra("day",0); int month1=month+1; text.setText("你好:"+str1); text1.setText("您的出生日期为"+year+"年"+month1+"月"+day+"日"); //开始从12张星座照片中取出照片 int []image={R.drawable.img,R.drawable.jinniu,R.drawable.shuang,R.drawable.juxie,R.drawable.shizi,R.drawable.chunv ,R.drawable.tiancheng,R.drawable.tianxie,R.drawable.sheshou,R.drawable.mojie,R.drawable.shuiping ,R.drawable.shuangyu,}; int []contentarr={R.string.白羊,R.string.金牛,R.string.双子, R.string.巨蟹,R.string.狮子,R.string.处女,R.string.天秤,R.string.天蝎,R.string.射手,R.string.摩羯,R.string.水瓶,R.string.双鱼}; int i=find(month1,day); //根据图片显示图片和文字 imag_imgzodiac.setImageResource(image[i]); text2.setText(contentarr[i]); text2.setMovementMethod(ScrollingMovementMethod.getInstance()); } private int find(int month1, int day) { int i=0; if(month1==3&&day>=21||month1==4&&day<=19){i=0;} if(month1==4&&day>=20||month1==5&&day<=20){i=1;} if(month1==5&&day>=21||month1==6&&day<=21){i=3;} if(month1==6&&day>=22||month1==7&&day<=22){i=2;} if(month1==7&&day>=23||month1==8&&day<=22){i=3;} if(month1==8&&day>=23||month1==9&&day<=22){i=4;} if(month1==9&&day>=23||month1==10&&day<=23){i=5;} if(month1==10&&day>=24||month1==11&&day<=25){i=6;} if(month1==11&&day>=26||month1==12&&day<=21){i=3;} if(month1==12&&day>=22||month1==1&&day<=19){i=3;} if(month1==1&&day>=20||month1==2&&day<=18){i=3;} if(month1==2&&day>=19||month1==3&&day<=20){i=3;} return i; } }
STRINGS:
<resources> <string name="app_name">My Applicationxingzuo</string> <string name="白羊">当行星落入白羊座守护星:火星 白羊座是从浩瀚的宇宙之火中取出的一束火把。 因此,它也象征太阳散发出的一束光芒。白羊座作为一个独立的自我诞生于广袤无际的宇宙意识,它通过源源不断的创造力来表达自己不同于集体的独特性。白羊座就像是年少时期的我们,身体里藏着无限的生命可能,但却不知道这些能量最终能创造出什么结果。</string> <string name="金牛"> 当行星落入金牛座守护星:金星 金牛座清楚地知道物质条件对于生命的重要意义,因此他们保守的特质不仅会将白羊座代表的生命律动具像化,也会将生命维持下去。金牛座会把精力集中在具体的有意义的活动之中。金牛座的哲学思维来源于生活中的常识,而不是抽象的哲学和理论教义。 </string> <string name="双子"> 当行星落入双子座守护星:水星 双子座在人、概念和事物之间的关系中培养理解力。在水星的掌管下,这些关系之间相互对立:物体和概念,视野和观众,意见和提出意见的人。本质上来说,双子座追求学习和解释世间万物。因此双子座必须学会分析:把事物拆解开。 </string> <string name="巨蟹"> 当行星落入巨蟹座守护星:月亮 巨蟹座代表的是基础、根源、部落、家庭,由此定义展开,它也代表我们与人类大家庭的集体意识的关系基调。巨蟹座永远在寻找家园,在人格层面上,居住环境(或缺乏)、家庭和谐(或混乱)、食物和营养(或对匮乏和饥饿的恐惧)对这个月亮之子来说非常重要。 </string> <string name="狮子"> 当行星落入狮子座守护星:太阳 宇宙的启示通过无私之爱传递给我我们,而狮子座自我意识的创造力将这一启示向外延伸并落实。狮子座代表的火象/固定星座的能量对于渴望走上灵修之路的人来说显得尤为重要。我们每个人的本命星盘都是以太阳为中心,因此太阳不仅仅主宰狮子座,它也是每一张星盘的能量中枢和引擎。 </string> <string name="处女"> 当行星落入处女座守护星:水星 处女座和第六宫要求我们运用技能、方法和准则从杂乱无章的业力和个性中得以自愈。这就是炼金术里“合成”的过程。我们通过处女座学会了鉴别力。水星进入处女座是吸引和阴性能量,它主导合成,原则是融合和治愈。 </string> <string name="天秤"> 当行星落入天秤座守护星:金星 天天秤座的生命能量表达要求个人深入理解生命经验的内在含义而非外在的物质层面。在此阶段,天秤座接纳了灵魂但还未与意识融合。因此它还处在多极之间的摆动状态:彰显个性和服务他人之间的欲望和拉扯,人生方向,超个人的高阶自我。 </string> <string name="天蝎"> 当行星落入天蝎座守护星:冥王星 一提到“转化”和“演变”这两个占星常用词汇,我们立马就会联想到天蝎座、冥王星和八宫的能量和特征。我们人类处在自然七界的中间,连接了低阶和高阶的能量场。天蝎座就是我们生命能量转化的中介。我们通过天蝎座的这扇转化之门,不是进化就是溶解,不是进步就是退步,不是重生就是死亡。 </string> <string name="射手"> 当行星落入射手座守护星:木星 太阳或上升射手座的格言就是:我发现了目标,达成了目标,然后继续寻找下一个目标。射手座就像是一位先知,总是向前探究未知的可能和潜力。他用力地拉满弓,射出了箭:“我朝天上射了一箭”。他手中的弓箭有着强大的力量,充满了志向之火、激情的想象和理想的愿景。 </string> <string name="摩羯"> 当行星落入魔羯座守护星:土星 魔羯座是三个土象星座中的最后一个,行星的能量在这里进入了成熟和收获期。行星经历了运动和发展的周期之后在魔羯座到达巅峰,我们每个人的个性发展也是如此。太阳或上升魔羯座的个性特点:魔羯座拥有山羊般的意志和求生本能,也能理解生命本身的能量和价值,不断地向山峰发起攻顶挑战。 </string> <string name="水瓶"> 当行星落入水瓶座守护星:天王星 水瓶时代由于守护星天王星的持续影响,“父亲”主导的社会结构发生了翻天覆地的变化。天王星要求我们每个人活出自我,成为自己的“太阳”,走向自我发展的舞台中央。如今在“个人主义”的模式下,我们每个人都要成为独立星系里的那一颗拥有创造力的恒星。 </string> <string name="双鱼"> 当行星落入双鱼座守护星:海王星 双鱼座的符号反映出了这个星座的二元性:两个半圆由一根横线连接起来;通常我们也把它视为两条鱼被一根绳索绑在一起。这两种象征其实都在描述灵魂和个性之间同时发生的吸引和排斥所带来的:质朴的热情,人世的苦难和人性的救赎。 </string> </resources>
THEMES:
<resources xmlns:tools="http://schemas.android.com/tools"> <!-- Base application theme. --> <style name="Theme.MyApplicationxingzuo" parent="Theme.MaterialComponents.DayNight.DarkActionBar.Bridge"> <!-- Primary brand color. --> <item name="colorPrimary">@color/purple_500</item> <item name="colorPrimaryVariant">@color/purple_700</item> <item name="colorOnPrimary">@color/white</item> <!-- Secondary brand color. --> <item name="colorSecondary">@color/teal_200</item> <item name="colorSecondaryVariant">@color/teal_700</item> <item name="colorOnSecondary">@color/black</item> <!-- Status bar color. --> <item name="android:statusBarColor">?attr/colorPrimaryVariant</item> <!-- Customize your theme here. --> </style> </resources>