安卓app_sl3.10游戏界面设计按钮点击事件-toast notification-弹出消息自动关闭
安卓app_sl3.10游戏界面设计按钮点击事件-toast notification-点击进入弹出消息自动关闭
package com.example.sl3_10; 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.ImageView; import android.widget.Toast; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ImageView img0=(ImageView)findViewById(R.id.imageButton0); img0.setOnClickListener(new OnClickListener() { @Override public void onClick(View v){ 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); } }
<LinearLayout xmlns: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" tools:context="com.example.sl3_10.MainActivity" > <ImageView android:id="@+id/imageView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:scaleType="centerCrop" android:layout_weight="1" android:src="@drawable/top" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/bottom" android:id="@+id/relativeLayout1" android:layout_weight="2" > <ImageView android:id="@+id/imageButton0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:src="@drawable/in" /> <ImageView android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/imageButton0" android:layout_alignRight="@+id/imageButton0" android:src="@drawable/setting" /> <ImageView android:id="@+id/imageButton2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/imageButton0" android:layout_alignLeft="@+id/imageButton0" android:src="@drawable/exit" /> <ImageView android:id="@+id/imageButton3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_alignTop="@+id/imageButton0" android:layout_toLeftOf="@+id/imageButton0" android:src="@drawable/help" /> <ImageView android:id="@+id/imageButton4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@+id/imageButton0" android:layout_alignTop="@+id/imageButton0" android:src="@drawable/board" /> </RelativeLayout> </LinearLayout>
欢迎讨论,相互学习。
cdtxw@foxmail.com
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
2020-02-15 ca13a_c++_顺序容器的操作6删除元素
2020-02-15 ca12a_c++顺序容器的操作5_访问容器中的数据元素
2020-02-15 cb11a_c++_顺序容器的操作4_容器大小操作_resize-max_size
2020-02-15 cb10a_c++_顺序容器的操作3关系运算符
2020-02-15 cb09a_c++_顺序容器的操作2-在顺序容器中添加元素_插入数据
2020-02-15 cb08a_c++_顺序容器的操作1
2020-02-15 cb07a_c++_迭代器和迭代器的范围