首页 文章 精选 留言 我的

精选列表

搜索[窗口预览],共10002篇文章
优秀的个人博客,低调大师

android登录简单窗口

下面是原代码: packagecom.smart.db; importandroid.content.Context; importandroid.database.sqlite.SQLiteDatabase; importandroid.database.sqlite.SQLiteOpenHelper; publicclassSQLiteextendsSQLiteOpenHelper{ publicstaticfinalStringTB_NAME="smrtDataBase"; //构造方法 publicSQLite(Contextcontext){ super(context,TB_NAME,null,1); } /** *创建数据库表 */ @Override publicvoidonCreate(SQLiteDatabasedb){ db.execSQL("CREATETABLEusers(userIdintegerprimarykeyautoincrement,namevarchar(20),passwordvarchar(20))"); } /** *当检测与前一次创建数据库版本不一样时,先删除表再创建新表 */ @Override publicvoidonUpgrade(SQLiteDatabasedb,intoldVersion,intnewVersion){ db.execSQL("DROPTABLEIFEXISTSusers"); onCreate(db); } } packagecom.smart.db; importandroid.content.ContentValues; importandroid.content.Context; importandroid.database.Cursor; importandroid.database.sqlite.SQLiteDatabase; publicclassUserImpl{ privateSQLitesqlite; privateContextcontent; privateSQLiteDatabasedb; publicUserImpl(Contextcontext){ sqlite=newSQLite(context); } //登录方法 publicCursorlogin(Stringname,Stringpwd){ SQLiteDatabasedatabase=sqlite.getReadableDatabase(); CursormCursor=database.query(true,"users",newString[]{"name"}, "name=?andpassword=?",newString[]{name,pwd},null, null,null,null); returnmCursor; } //保存方法 publicbooleansave(Stringname,Stringpassword){ SQLiteDatabasedatabase=sqlite.getWritableDatabase(); ContentValuesvalues=newContentValues(); values.put("name",name); values.put("password",password); //必须添加记录,除了主键之处,其它都要null database.insert("users","name",values); returntrue; } } packagecom.smart.loginActivity; importcom.smart.db.UserImpl; importandroid.app.Activity; importandroid.database.Cursor; importandroid.os.Bundle; importandroid.util.Log; importandroid.view.View; importandroid.view.View.OnClickListener; importandroid.widget.Button; importandroid.widget.EditText; importandroid.widget.Toast; publicclassLoginMainextendsActivity{ privatestaticfinalStringTAG="LoginMain"; privateButtonok; privateButtonexit; privateEditTextname; privateEditTextpassword; @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main);//得到控件 ok=(Button)findViewById(R.id.ok); exit=(Button)findViewById(R.id.exit); name=(EditText)findViewById(R.id.username); password=(EditText)findViewById(R.id.password); ok.setOnClickListener(newOnClickListener(){//方法编写 @Override publicvoidonClick(Viewv){ Log.i(TAG,name.getText().toString()+"<----passord---->" +password.getText().toString()); try{ UserImplimpl=newUserImpl(LoginMain.this); Cursorcursor=impl.login(name.getText().toString(),password.getText().toString());//得到记录 if(cursor.moveToNext()){//进行判断数据库当中是否有记得 Toast.makeText(LoginMain.this,"成功登录!",Toast.LENGTH_LONG) .show(); }else{ Toast.makeText(LoginMain.this,"你的用户名或密码错误,请重新输入", Toast.LENGTH_LONG).show(); name.setText(""); password.setText(""); } }catch(Exceptione){ Log.i(TAG,"报错了"); } } }); //取消 exit.setOnClickListener(newOnClickListener(){ @Override publicvoidonClick(Viewv){ Log.i(TAG,name.getText().toString()+"<----passord---->" +password.getText().toString()); Toast.makeText(LoginMain.this,"你点击了取消!",Toast.LENGTH_LONG) .show(); finish(); } }); } } <?xmlversion="1.0"encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayoutandroid:orientation="horizontal"android:layout_width="wrap_content"android:layout_height="wrap_content"> <TextView android:layout_width="100dip" android:layout_height="wrap_content" android:text="@string/userName" /> <EditText android:layout_width="200dip" android:layout_height="wrap_content" android:textSize="15dip" android:id="@+id/username" /> </LinearLayout> <LinearLayoutandroid:orientation="horizontal"android:layout_width="wrap_content"android:layout_height="wrap_content"> <TextView android:layout_width="100dip" android:layout_height="wrap_content" android:text="@string/userPwd" /> <EditText android:layout_width="200dip" android:layout_height="wrap_content" android:textSize="15dip" android:id="@+id/password" android:password="true" /> </LinearLayout> <LinearLayoutandroid:orientation="horizontal"android:layout_width="wrap_content"android:layout_height="wrap_content"> <Button android:layout_width="100dip" android:layout_height="wrap_content" android:text="@string/ok" android:id="@+id/ok" /> <Button android:layout_width="100dip" android:layout_height="wrap_content" android:text="@string/exit" android:id="@+id/exit" /> </LinearLayout> </LinearLayout> 本文转自 llb988 51CTO博客,原文链接:http://blog.51cto.com/llb988/531777,如需转载请自行联系原作者

优秀的个人博客,低调大师

ECMAScript 2021 特性预览

最新举行的一次 TC39 会议正式确定了 ECMAScript 2021 的完整功能列表。具体包含以下内容: String.prototype.replaceAll 此前,如果想要替换所有的 string occurrences,则需要使用 String.prototype.replace 和全局 regexp 的组合。现在,String.prototype.replaceAll简化了这一点。 const string = "it-is-just-a-test"; // instead of doing this string.replace(/-/g, "_") // "it_is_just_a_test" // in ES2021 we can do string.replaceAll("-", "_") // "it_is_just_a_test" Promise.any 将 Promise.any 加入了 2021 年规范中的 Promise combinators 列表。当你想处理第一个 fulfills 的 Promise 时,可以使用 Promise.any。与 Promise.race 不同,当其中一个 promises fail 时,它不会 reject。更多详情可查看“Promise combinators explained”。 const API = "https://api.github.com/users" Promise.any([ fetch(`${API}/pawelgrzybek`), fetch(`${API}/gabriel403`) ]) .then(response => response.json()) .then(({name}) => console.log(`Cool dude is: ${name}`)) .catch(error => console.error(error)); WeakRefs WeakRefs 提案为语言带来了两个新的 contructors:WeakRef 和 FinalizationRegistry。这些新功能是更复杂、更低级的语言概念。 WeakRef 当将一个对象分配给一个变量时,它指向存储这个对象的值的那块内存(强引用)。如果程序不再引用这个对象,garbage collector会销毁它并回收内存。WeakRef 的一个实例创建了一个对给定对象的引用,如果该对象仍然在内存中,则返回该对象;如果目标对象已经被垃圾回收,则返回未定义的对象。 const obj = { spec: "ES2021" }; const objWeakRef = new WeakRef(obj); // do something cool objWeakRef.deref(); // returns obj in case it is still in memory // returns undefined in case it has been garbage collected FinalizationRegistry FinalizationRegistry 的实例在注册的目标对象被垃圾收集后触发回调函数。 const obj = { spec: "ES2021" }; const registry = new FinalizationRegistry(value => { console.log(`The ${value} object has been garbage collected.`) }); registry.register(obj, "ECMAScript 2021"); // perform some action that triggers garbage collector on obj // The ECMAScript 2021 object has been garbage collected. 值得注意的是,官方提示要尽量避免使用WeakRef和FinalizationRegistry,垃圾回收机制依赖于 JavaScript 引擎的实现,不同的引擎或是不同版本的引擎可能会有所不同。 Logical Assignment Operators 顾名思义,逻辑赋值运算符是逻辑运算符(&&, || and ??)和赋值运算符(=)的组合。 // set a to b only when a is truthy a &&= b; // set a to b only when a is falsy a ||= b; // set a to b only when a is nullish a ??= b; Numeric separators 数字的可读性随着数字长度的增加而降低。现在,则可以使用下划线(_, U+005F)来分隔数字组,使得长数字更加清晰可读。这个功能在 Java、Python、Perl、Ruby、Rust、Julia、Ada、C#等其他编程语言中也很有名。 const population = 37_653_260 详情可查看:https://pawelgrzybek.com/whats-new-in-ecmascript-2021/

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册