我的记事本项目之路(一)
来源:互联网 发布:区块链 对等网络 编辑:程序博客网 时间:2024/04/30 13:28
首先你得先想好你要做个什么样的记事本,它有什么样的功能呢?
第一步先给它做一个登录界面,登录界面这里我采用的是关系布局也就是RelativeLayout,
第二步采用表格布局TableLayout用来布局用户名和密码框,这里采用两组TextView与EditText,
第三步在设置两个Button按钮分别为登录和注册.
login.xml的具体代码如下:
<RelativeLayout 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:background="#ADFF2F"
android:layout_marginTop="8dip"
android:layout_marginBottom="8dip"
android:layout_marginLeft="8dip"
android:layout_marginRight="8dip"
>
<TableLayout
android:id="@+id/loginForm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.JiShiBen.LoginDialog"
android:background="#ADFF2F"
>
<TableRow>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="用户名"
android:textSize="15pt" />
<!-- 输入用户名的文本框 -->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请填写登录账号"
android:selectAllOnFocus="true" />
</TableRow>
<TableRow>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="密码:"
android:textSize="15pt" />
<!-- 输入密码的文本框 -->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:password="true" />
</TableRow>
</TableLayout>
<Button
android:id="@+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/loginForm"
android:text="登录"
/>
<Button
android:id="@+id/btnLoginS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/btn_login"
android:layout_alignParentRight="true"
android:text="注册" />
</RelativeLayout>
然后就是登录功能的Activity的实现,这里由于是新手项目,所以没有复杂的验证功能,就实现一个简单的功能,点击登录后跳转LoginActivity.java的代码如下:
package com.example.jishiben;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class LoginActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
Button bn = (Button) findViewById(R.id.btn_login);
BtnOnClickListener listener = new BtnOnClickListener();
bn.setOnClickListener(listener);
}
class BtnOnClickListener implements OnClickListener {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(LoginActivity.this, MainActivity.class);
startActivity(intent);
}
}
}
要看精彩内容,请看下回分解.
- 我的记事本项目之路(一)
- 我的记事本项目之路(二)
- 我的记事本项目之路(三)
- 我的记事本项目之路(四)
- 我的记事本项目之路(五)
- 我的Java之路——一 记事本编写Java小程序
- 我的记事本之--管理记事
- Java小程序之我的记事本
- 我的项目之路图书管理系统(一)
- 我的记事本
- 我的记事本
- 我的记事本
- 我的记事本
- 我的记事本程序
- java-我的记事本
- 我的记事本
- 我的记事本之-SQLite数据库的使用
- 记事本源程序我的课程设计
- C++数据结构环形队列Deque实现
- Java国际化及Spring国际化解决方法
- JDBC:Spring框架中JDBCTemplate的使用
- Java线程池管理及分布式Hadoop调度框架搭建
- iOS中自定义导航控制器NavigationController
- 我的记事本项目之路(一)
- 使用文本/CAD数据集添加地图注记
- 中断请求级别
- 初次开通,多多赐教!
- 3D mesh 的质量评估(Perceptual Metrics Quality)
- Hibernate面试题及答案
- vim 多个标签之间切换
- clojure实战——基于logstash搭建日志数据获取与整理平台(2)
- UNIX Tutorial Two