Android小程序实现简易QQ界面
GPT4.0+Midjourney绘画+国内大模型 会员永久免费使用!
【 如果你想靠AI翻身,你先需要一个靠谱的工具! 】
本文实例为大家分享了Android实现简易QQ界面的具体代码,供大家参考,具体内容如下
要求:
(1)与QQ界面控件数目、样式相同
(2)与QQ的图形化界面相同
(3)实现一个简单的点击事件
具体实现:
(1)编写程序代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | package com.example.login; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.Window; import android.widget.Button; import android.widget.EditText; import android.widget.RadioButton; import android.widget.Toast; import android.widget.ToggleButton; public class MainActivity extends Activity { //声明组件 private EditText username; private EditText password; private Button login; @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); //无标题设置 requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); //初始化控件,根据Id获取组件对象 username = (EditText)findViewById(R.id.username); password = (EditText)findViewById(R.id.password); login = (Button)findViewById(R.id.login); //注册监听 login.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // 登录 Log.i( "tag" , "username:" +username.getText().toString()); Log.i( "tag" , "password:" +password.getText().toString()); Toast t1 = Toast.makeText(getApplicationContext(), "登录成功" , Toast.LENGTH_LONG); t1.show(); } }); } } |
(2)对应布局文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | < LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" android:layout_width = "match_parent" android:layout_height = "match_parent" android:background = "@drawable/aa" android:orientation = "vertical" > < LinearLayout android:layout_width = "match_parent" android:layout_height = "match_parent" android:background = "#55000000" android:orientation = "vertical" android:paddingLeft = "30dp" android:paddingRight = "30dp" > < LinearLayout android:layout_marginTop = "80dp" android:layout_width = "match_parent" android:layout_height = "wrap_content" android:gravity = "center_vertical" android:orientation = "horizontal" > < ImageView android:layout_width = "43dp" android:layout_height = "43dp" android:src = "@drawable/qq" /> < TextView android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "QQ" android:textColor = "#fff" android:textSize = "50dp" /> </ LinearLayout > < EditText android:id = "@+id/username" android:layout_width = "match_parent" android:layout_height = "wrap_content" android:layout_marginTop = "30dp" android:background = "@null" android:hint = "QQ号/手机号/邮箱" android:maxLength = "13" android:singleLine = "true" android:textColor = "#fff" android:textSize = "30px" android:textColorHint = "#eee" /> < View android:layout_width = "match_parent" android:layout_height = "1px" android:layout_marginTop = "10dp" android:background = "#eee" /> < EditText android:id = "@+id/password" android:layout_width = "match_parent" android:layout_height = "wrap_content" android:layout_marginTop = "10dp" android:background = "@null" android:hint = "密码" android:inputType = "textPassword" android:maxLength = "13" android:singleLine = "true" android:textColor = "#fff" android:textSize = "30px" android:textColorHint = "#eee" /> < View android:layout_width = "match_parent" android:layout_height = "1px" android:layout_marginTop = "10dp" android:background = "#eee" /> < Button android:id = "@+id/login" android:layout_width = "match_parent" android:layout_height = "wrap_content" android:layout_marginTop = "10dp" android:background = "@drawable/button_login_bg" android:text = "登录" android:textColor = "#fff" android:textSize = "25px" /> < LinearLayout android:layout_width = "match_parent" android:layout_height = "wrap_content" android:layout_marginTop = "10dp" android:orientation = "horizontal" > < TextView android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_weight = "1" android:text = "忘记密码?" android:textColor = "#cc1CA4DE" android:textSize = "20dp" /> < TextView android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_weight = "1" android:gravity = "right" android:text = "新用户注册" android:textColor = "#cc1CA4DE" android:textSize = "20dp" /> </ LinearLayout > </ LinearLayout > </ LinearLayout > |
(3)效果如下:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
微信公众号搜索 “ 脚本之家 ” ,选择关注
程序猿的那些事、送书等活动等着你
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权/违法违规/事实不符,请将相关资料发送至 reterry123@163.com 进行投诉反馈,一经查实,立即处理!
相关文章
ViewPager和SlidingPaneLayout的滑动事件冲突解决方法
下面小编就为大家分享一篇ViewPager和SlidingPaneLayout的滑动事件冲突解决方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2018-01-01Flutter最小刷新范围探索ValueListenableBuilder使用详解
这篇文章主要为大家介绍了Flutter最小刷新范围探索ValueListenableBuilder使用详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2022-12-12Flutter StaggeredGridView实现瀑布流效果
这篇文章主要为大家详细介绍了Flutter StaggeredGridView实现瀑布流效果,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2022-03-03Android基于ListView实现类似QQ空间的滚动翻页与滚动加载效果
这篇文章主要介绍了Android基于ListView实现类似QQ空间的滚动翻页与滚动加载效果,涉及ListView相关属性与方法的操作技巧,需要的朋友可以参考下2016-08-08
最新评论