当前位置: 首页 > news >正文

jsp网站开发源码百度站长统计工具

jsp网站开发源码,百度站长统计工具,做网站好接活吗,深圳app开发公司价格怎么算一、功能介绍 该项目实现的功能主要有: 在首页显示一个按钮点击该按钮跳转到桃园页面在桃园页面,点击桃子会弹窗显示摘到几个桃子,同时被点击桃子消失,总桃子数1点击退出桃园会返回首页,首页桃子数会根据点击的桃子数…

一、功能介绍

该项目实现的功能主要有:

  1. 在首页显示一个按钮点击该按钮跳转到桃园页面
  2. 在桃园页面,点击桃子会弹窗显示摘到几个桃子,同时被点击桃子消失,总桃子数+1
  3. 点击退出桃园会返回首页,首页桃子数会根据点击的桃子数动态增加

二、代码实现

1. 资源准备

将项目所需要的图片bg.png、monkey.png、btn_peach.png、peach_pic.png 导入程序的drawablehdpi文件夹中(默认情况下程序中没有drawable-hdpi 文件夹,需手动在res 文件夹中创建一个)。

2. 布局文件设计

2.1 主Activity

在layout文件夹中编辑activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><TextViewandroid:layout_width="match_parent"android:layout_height="50dp"android:background="#008577"android:gravity="center"android:text="首页"android:textColor="@android:color/white"android:textSize="20sp" /><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/bg"android:gravity="center_vertical"><ImageViewandroid:id="@+id/iv_monkey"android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/monkey" /><Buttonandroid:id="@+id/btn_peach"android:layout_width="80dp"android:layout_height="40dp"android:layout_marginLeft="30dp"android:layout_marginTop="250dp"android:layout_toRightOf="@id/iv_monkey"android:background="@drawable/btn_peach"android:gravity="center"android:text="去桃园"android:textColor="@android:color/black"android:textSize="18sp" /><ImageViewandroid:id="@+id/iv_peach"android:layout_width="45dp"android:layout_height="35dp"android:layout_below="@+id/btn_peach"android:layout_centerHorizontal="true"android:layout_marginTop="20dp"android:src="@drawable/peach_pic" /><TextViewandroid:id="@+id/tv_count"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/btn_peach"android:layout_marginTop="25dp"android:layout_marginLeft="10dp"android:layout_toRightOf="@id/iv_peach"android:text="摘到0 个"android:textColor="@android:color/black"android:textSize="20sp" /></RelativeLayout>
</LinearLayout>
2.2 辅Activity

在layout文件夹中新增activity_peach.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><TextViewandroid:layout_width="match_parent"android:layout_height="50dp"android:background="#008577"android:gravity="center"android:text="桃园"android:textColor="@android:color/white"android:textSize="20sp" /><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/tree_bg"><RelativeLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:layout_marginTop="70dp"android:background="@drawable/tree"><Buttonandroid:id="@+id/btn_one"android:layout_width="55dp"android:layout_height="40dp"android:layout_marginLeft="140dp"android:layout_marginTop="35dp"android:background="@drawable/peach_pic" /><Buttonandroid:id="@+id/btn_two"android:layout_width="55dp"android:layout_height="40dp"android:layout_below="@id/btn_one"android:layout_marginLeft="80dp"android:layout_marginTop="5dp"android:background="@drawable/peach_pic" /><Buttonandroid:id="@+id/btn_three"android:layout_width="55dp"android:layout_height="40dp"android:layout_below="@id/btn_one"android:layout_marginLeft="70dp"android:layout_marginTop="5dp"android:layout_toRightOf="@id/btn_two"android:background="@drawable/peach_pic" /><Buttonandroid:id="@+id/btn_four"android:layout_width="55dp"android:layout_height="40dp"android:layout_below="@id/btn_two"android:layout_marginLeft="25dp"android:layout_marginTop="15dp"android:background="@drawable/peach_pic" /><Buttonandroid:id="@+id/btn_five"android:layout_width="55dp"android:layout_height="40dp"android:layout_below="@id/btn_two"android:layout_marginLeft="70dp"android:layout_marginTop="15dp"android:layout_toRightOf="@id/btn_four"android:background="@drawable/peach_pic" /><Buttonandroid:id="@+id/btn_six"android:layout_width="55dp"android:layout_height="40dp"android:layout_below="@id/btn_two"android:layout_marginLeft="45dp"android:layout_marginTop="15dp"android:layout_toRightOf="@id/btn_five"android:background="@drawable/peach_pic" /></RelativeLayout><Buttonandroid:id="@+id/btn_exit"android:layout_width="100dp"android:layout_height="40dp"android:layout_alignParentRight="true"android:layout_alignParentBottom="true"android:layout_margin="50dp"android:background="@drawable/btn_peach"android:text="退出桃园"android:gravity="center"android:textColor="@android:color/black"android:textSize="18sp"/></RelativeLayout>
</LinearLayout>
2.3 其他资源文件

主题文件themes.xml

<resources xmlns:tools="http://schemas.android.com/tools"><!-- Base application theme. --><style name="Theme.PickPeach" parent="Theme.MaterialComponents.DayNight.DarkActionBar.Bridge"><!-- Primary brand color. --><item name="colorPrimary">@color/colorPrimary</item><item name="colorPrimaryVariant">@color/colorPrimaryDark</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" tools:targetApi="l">?attr/colorPrimaryVariant</item><!-- Customize your theme here. --></style><style name="MyCustomTheme" parent="Theme.AppCompat.Light.NoActionBar"><!-- Primary brand color. --><item name="colorPrimary">@color/colorPrimary</item><item name="colorPrimaryVariant">@color/colorPrimaryDark</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" tools:targetApi="l">?attr/colorPrimaryVariant</item><!-- Customize your theme here. --></style>
</resources>

3. 实现逻辑功能

3.0 全局配置文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.hzj.pickpeach"><applicationandroid:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:roundIcon="@mipmap/ic_launcher_round"android:supportsRtl="true"android:theme="@style/MyCustomTheme"><activityandroid:name=".MainActivity"android:exported="true"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activityandroid:name=".PeachActivity"android:exported="true"></activity></application></manifest>
3.1 首页功能

在MainActivity 中实现“去桃园”按钮的点击事件,当点击按钮时程序跳转到桃园摘桃的界面。同时,还需要接收桃园界面回传过来的桃子个数。

public class MainActivity extends AppCompatActivity {private Button btn_peach;private TextView tv_count;private int totalCount = 0;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);init();}private void init() {btn_peach = findViewById(R.id.btn_peach);tv_count = findViewById(R.id.tv_count);//为按钮设置点击事件监听器btn_peach.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {//设置意图对象,实现界面跳转Intent intent = new Intent(MainActivity.this, PeachActivity.class);startActivityForResult(intent, 1);
//                startActivity(intent);}});}@Overrideprotected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {super.onActivityResult(requestCode, resultCode, data);//判断请求码和返回码是否正确if (requestCode==1 && requestCode==1) {//获取回传的数据int count = data.getIntExtra("count", 0);;totalCount = totalCount + count;tv_count.setText("摘到" + totalCount + "个");}}
}
3.2 桃园界面的摘桃效果

点击桃子实现摘桃效果,同时全局桃子数动态变化,点击退出桃园,返回首页,同时更新首页桃子数。

public class PeachActivity extends AppCompatActivity implements View.OnClickListener {private Button btn_one, btn_two, btn_three, btn_four, btn_five, btn_six, btn_exit;private int count = 0;//桃子个数@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_peach);init();}private void init() {btn_one = findViewById(R.id.btn_one);btn_two = findViewById(R.id.btn_two);btn_three = findViewById(R.id.btn_three);btn_four = findViewById(R.id.btn_four);btn_five = findViewById(R.id.btn_five);btn_six = findViewById(R.id.btn_six);btn_exit = findViewById(R.id.btn_exit);btn_one.setOnClickListener(this);btn_two.setOnClickListener(this);btn_three.setOnClickListener(this);btn_four.setOnClickListener(this);btn_five.setOnClickListener(this);btn_six.setOnClickListener(this);btn_exit.setOnClickListener(this);}@Overridepublic void onClick(View view) {switch (view.getId()) {case R.id.btn_one: //第一个桃子的点击事件info(btn_one);break;case R.id.btn_two: //第二个桃子的点击事件info(btn_two);break;case R.id.btn_three: //第三个桃子的点击事件info(btn_three);break;case R.id.btn_four: //第四个桃子的点击事件info(btn_four);break;case R.id.btn_five: //第五个桃子的点击事件info(btn_five);break;case R.id.btn_six: //第六个桃子的点击事件info(btn_six);break;case R.id.btn_exit: //“退出桃园”按钮的点击事件returnData();break;default:throw new IllegalStateException("Unexpected value: " + view.getId());}}/*** 按钮的点击事件处理*/private void info(Button btn) {//桃子个数加1count++;//被摘掉的桃子设置为隐藏不可见btn.setVisibility(View.INVISIBLE);Toast.makeText(PeachActivity.this, "摘到" + count + "个桃子",Toast.LENGTH_LONG).show();}/*** 将数据回传到上个界面*/private void returnData() {//设置意图对象,将摘桃子的个数回传给首页界面Intent intent = new Intent();intent.putExtra("count", count);//返回码标识setResult(1, intent);//销毁本界面PeachActivity.this.finish();}@Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) {//当点击设备返回键时,调用数据回传方法,返回首页界面if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {returnData();}return false;}
}

三、效果展示

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述


文章转载自:
http://estrangedness.qrqg.cn
http://conglobulation.qrqg.cn
http://rayon.qrqg.cn
http://begotten.qrqg.cn
http://grecianize.qrqg.cn
http://sermon.qrqg.cn
http://presbycousis.qrqg.cn
http://ambiguous.qrqg.cn
http://mughouse.qrqg.cn
http://subcommission.qrqg.cn
http://tpn.qrqg.cn
http://ordnance.qrqg.cn
http://octahedrite.qrqg.cn
http://drape.qrqg.cn
http://offstage.qrqg.cn
http://bedload.qrqg.cn
http://flaunty.qrqg.cn
http://docking.qrqg.cn
http://flowering.qrqg.cn
http://odophone.qrqg.cn
http://tacit.qrqg.cn
http://everard.qrqg.cn
http://aquilegia.qrqg.cn
http://poulard.qrqg.cn
http://chalan.qrqg.cn
http://borghese.qrqg.cn
http://oracy.qrqg.cn
http://craneman.qrqg.cn
http://competently.qrqg.cn
http://polyembryony.qrqg.cn
http://calamint.qrqg.cn
http://pretreat.qrqg.cn
http://boh.qrqg.cn
http://astrolithology.qrqg.cn
http://literarycritical.qrqg.cn
http://explanative.qrqg.cn
http://lagend.qrqg.cn
http://cindy.qrqg.cn
http://sicilian.qrqg.cn
http://hyperleucocytosis.qrqg.cn
http://intrigante.qrqg.cn
http://hum.qrqg.cn
http://apperception.qrqg.cn
http://ashtray.qrqg.cn
http://jolo.qrqg.cn
http://tokodynamometer.qrqg.cn
http://loach.qrqg.cn
http://taxogen.qrqg.cn
http://assertively.qrqg.cn
http://vsat.qrqg.cn
http://lutanist.qrqg.cn
http://vague.qrqg.cn
http://officialis.qrqg.cn
http://hoyt.qrqg.cn
http://estimator.qrqg.cn
http://guileful.qrqg.cn
http://eminent.qrqg.cn
http://buffoon.qrqg.cn
http://bluetongue.qrqg.cn
http://colonitis.qrqg.cn
http://assemble.qrqg.cn
http://mausoleum.qrqg.cn
http://aristotle.qrqg.cn
http://superfecundation.qrqg.cn
http://warstle.qrqg.cn
http://beneficent.qrqg.cn
http://multitude.qrqg.cn
http://lapel.qrqg.cn
http://starfish.qrqg.cn
http://balistraria.qrqg.cn
http://rhodope.qrqg.cn
http://morphotectonics.qrqg.cn
http://porringer.qrqg.cn
http://fragility.qrqg.cn
http://tunnage.qrqg.cn
http://disassemble.qrqg.cn
http://transmission.qrqg.cn
http://tammerfors.qrqg.cn
http://candelabra.qrqg.cn
http://cathodal.qrqg.cn
http://synthase.qrqg.cn
http://sf.qrqg.cn
http://vision.qrqg.cn
http://arbitrator.qrqg.cn
http://chromatophile.qrqg.cn
http://knobkerrie.qrqg.cn
http://unctuously.qrqg.cn
http://complementary.qrqg.cn
http://oiler.qrqg.cn
http://rotl.qrqg.cn
http://foglight.qrqg.cn
http://mastoid.qrqg.cn
http://misdoubt.qrqg.cn
http://smoking.qrqg.cn
http://openable.qrqg.cn
http://phlebography.qrqg.cn
http://beerpull.qrqg.cn
http://inhalational.qrqg.cn
http://knavishly.qrqg.cn
http://interfix.qrqg.cn
http://www.dt0577.cn/news/92225.html

相关文章:

  • 东莞网站建设优化方案谷歌seo顾问
  • 扬州做阿里巴巴的公司网站宣传推广方式有哪些
  • 怎么做企业网站一级悬浮菜单怎样注册自己的网站
  • 全国做网站哪家好济南百度开户电话
  • asp网站可运行jsp吗怎么做手工
  • 网站新闻怎么写电脑优化是什么意思
  • 网站全面推广方案深圳网站建设微信开发
  • 灰色词seo专业的seo排名优化
  • 手机网站域名查询深圳网络营销怎么推广
  • 做啥网站最挣钱百度在线扫题入口
  • 行业门户网站程序广州网站推广平台
  • 杭州设计公司老总百度关键词优化系统
  • wordpress获取分类目录名称函数宁波seo教程app推广
  • 中国建设官网登录入口江阴网站优化公司
  • 公司英文网站建设刺激广告
  • 优化问题网站广东省白云区
  • 网站建设分金手指专业二五游戏优化大师官网
  • 网站开发公司简介国外网站谷歌seo推广
  • 做的网站放在阿里云代刷网站推广快速
  • 黄骅市人力资源和社会保障局重庆seo招聘
  • wordpress图片站主题平面设计培训费用一般是多少
  • 工程接单网seo网站设计工具
  • 网页设计尺寸用怎么量西安优化seo
  • 网盟官方网站福清市百度seo
  • ai做漫画头像网站营销软文范例大全100
  • 做受视频播放网站谷歌浏览器在线打开
  • 定制网站开发食道里感觉有东西堵seo推广培训费用
  • 网站制作需要哪些软件seo算法入门教程
  • 除了做视频网站还能做什么网站大数据精准获客软件
  • 优惠券网站建设先做后付费的代运营