码迷,mamicode.com
首页 > 移动开发 > 详细

移动应用技术开发大作业——Android平台个人简历

时间:2016-05-13 14:59:57      阅读:304      评论:0      收藏:0      [点我收藏+]

标签:

这门水课一学期就三四节,两节Android一节ios,就要交大作业了。
出于兴趣自己开始自学,先是做了个简单的登录界面,再跟从CSDN上下载的仿知乎日报模板结合了一下。
由于要交作业,花一整天的时间完成了这个app的开发。
功能是个人简历介绍。

项目结构
技术分享
技术分享


MainActivity

使用的之前写的登录界面

xml代码:

(两个输入文本 一个登陆按钮 范佩西背景图)

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.example.zonzi.myresume.MainActivity" >

    <!-- Login progress -->

    <LinearLayout
        android:id="@+id/login_status"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center_horizontal"
        android:orientation="vertical"
        android:visibility="gone" >

        <ProgressBar
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp" />

        <TextView
            android:id="@+id/login_status_message"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="16dp"
            android:fontFamily="sans-serif-light"
            android:text="111111111111111"
            android:textAppearance="?android:attr/textAppearanceMedium" />
    </LinearLayout>

    <!-- Login form -->

    <RelativeLayout
        android:id="@+id/login_form"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@mipmap/rvpcover" >

        <EditText
            android:id="@+id/EditText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_above="@+id/EditText2"
            android:hint="用户名"
            android:inputType="textEmailAddress"
            android:maxLines="1"
            android:singleLine="true" />

        <EditText
            android:id="@+id/EditText2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_above="@+id/sign_in_button"
            android:hint="密码"
            android:imeActionId="@+id/login"
            android:imeActionLabel="2222222"
            android:imeOptions="actionUnspecified"
            android:inputType="textPassword"
            android:maxLines="1"
            android:singleLine="true" />

        <Button
            android:id="@+id/sign_in_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_margin="20dp"
            android:paddingLeft="32dp"
            android:paddingRight="32dp"
            android:text="登录" />

    </RelativeLayout>

</merge>

效果图
技术分享

.java代码

(判断用户输入的用户名密码是否正确,正确后跳转HomeActivity)
(用户名:B14040525 密码:123456)
(用户名密码判断的方法第一次写有错,不知原因,注释后另一种相似的方法却可行)

package com.example.zonzi.myresume;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    private Button mLogin = null;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        final EditText edit_UserName = (EditText)findViewById(R.id.EditText1);  //get what the user input from edittext1
        final EditText edit_Password = (EditText)findViewById(R.id.EditText2);  //get what the user input from edittext2



//        String saveusername = "";                                          //save what the user input
//        EditText getusername = (EditText) findViewById(R.id.EditText1);    //get it from edittext
//        saveusername = getusername.getText().toString();                 //change into string form
//
//        String savepassword = "";
//        EditText getpassword = (EditText) findViewById(R.id.EditText2);
//        savepassword = getpassword.getText().toString();

        final String cusername = this.getString(R.string.correctusername);  //get the correct username

        final String cpassword = this.getString(R.string.correctpassword);  //get the correct password

//        final String finalSaveUsername = saveusername;

//        final String finalSavepassword = savepassword;

        Button mLogin = (Button) findViewById(R.id.sign_in_button);
        mLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //compare the input with the correct username and password
                if(edit_UserName.getText().toString().trim().equals(cusername) && edit_Password.getText().toString().trim().equals(cpassword)){
//                if ((finalSaveUsername.equals(cusername)) && (finalSavepassword.equals(cpassword))) {
                    Intent i = new Intent(MainActivity.this, HomeActivity.class);   //jump to a new activity
                    startActivity(i);
                } else {
                    Toast.makeText(MainActivity.this, "用户名或密码错误", Toast.LENGTH_SHORT).show();   //error
                }
            }
        });
    }

}

HomeActivity

activity_home.xml代码

从左拖出的抽屉

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_home"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_home"
        app:menu="@menu/activity_home_drawer" />

</android.support.v4.widget.DrawerLayout>

效果图
技术分享

从左拖出的抽屉的头部

<?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="@dimen/nav_header_height"
    android:background="@drawable/side_nav_bar"
    android:gravity="bottom"
    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"
    android:theme="@style/ThemeOverlay.AppCompat.Dark">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/nav_header_vertical_spacing"
        android:src="@android:drawable/sym_def_app_icon" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/nav_header_vertical_spacing"
        android:text="B14040525 梁钟智"
        android:textAppearance="@style/TextAppearance.AppCompat.Body1" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="baszz@outlook.com" />

</LinearLayout>

效果图
技术分享

content_home.xml

也就是点击Introduction进入的页面。
个人信息。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.example.zonzi.myresume.HomeActivity"
    tools:showIn="@layout/app_bar_home">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerHorizontal="true"
        android:layout_alignParentTop="true">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="姓名"
            android:id="@+id/textView2"
            android:layout_alignParentTop="true"
            android:layout_alignStart="@+id/textView3" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="梁钟智"
            android:id="@+id/textView3"
            android:layout_below="@+id/textView2"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="性别"
            android:id="@+id/textView4"
            android:layout_below="@+id/textView3"
            android:layout_alignStart="@+id/textView3"
            android:layout_marginTop="30dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="男"
            android:id="@+id/textView5"
            android:layout_below="@+id/textView4"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="年龄"
            android:id="@+id/textView6"
            android:layout_below="@+id/textView5"
            android:layout_alignLeft="@+id/textView4"
            android:layout_marginTop="30dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="20"
            android:id="@+id/textView7"
            android:layout_below="@+id/textView6"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="学校"
            android:id="@+id/textView8"
            android:layout_below="@+id/textView7"
            android:layout_alignLeft="@+id/textView6"
            android:layout_marginTop="30dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="南京邮电大学"
            android:id="@+id/textView9"
            android:layout_below="@+id/textView8"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="专业"
            android:id="@+id/textView10"
            android:layout_below="@+id/textView9"
            android:layout_alignLeft="@+id/textView6"
            android:layout_marginTop="30dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="计算机科学与技术"
            android:id="@+id/textView11"
            android:layout_below="@+id/textView10"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="籍贯"
            android:id="@+id/textView12"
            android:layout_below="@+id/textView11"
            android:layout_alignLeft="@+id/textView6"
            android:layout_marginTop="30dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="广东"
            android:id="@+id/textView13"
            android:layout_below="@+id/textView12"
            android:layout_centerHorizontal="true" />
    </RelativeLayout>
</RelativeLayout>

效果图
技术分享

activity_home.java

让用户选择抽屉

package com.example.zonzi.myresume;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

public class HomeActivity extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();

        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
    }

    @Override
    public void onBackPressed() {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.home, 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.

        //jump to SettingsActivity
        Intent i = new Intent(HomeActivity.this,SettingsActivity.class);
        startActivity(i);

        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    @SuppressWarnings("StatementWithEmptyBody")
    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        // Handle navigation view item clicks here.
        int id = item.getItemId();

        if (id == R.id.nav_camera) {
            // Handle the camera action
        } else if (id == R.id.nav_gallery) {
            //jump to ExperienceActivity
            Intent i = new Intent(HomeActivity.this,ExperienceActivity.class);
            startActivity(i);
        } else if (id == R.id.nav_slideshow) {
            //jump to EducationActivity
            Intent i = new Intent(HomeActivity.this,EducationActivity.class);
            startActivity(i);
//        } else if (id == R.id.nav_manage) {

        } else if (id == R.id.nav_share) {
            //jump to ContactActivity
            Intent i = new Intent(HomeActivity.this,ContactActivity.class);
            startActivity(i);
//        } else if (id == R.id.nav_send) {

        }

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
        return true;
    }
}

ExperienceActivity

点击抽屉中的Experience后进入页面

experience_activity.xml

详细个人经历及获奖情况
大文本内容写在Strings.xml里

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.example.zonzi.myresume.ExperienceActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/app_bar_height"
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_experience" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email"
        app:layout_anchor="@id/app_bar"
        app:layout_anchorGravity="bottom|end" />

</android.support.design.widget.CoordinatorLayout>

效果图
技术分享

EducationActivity

点击抽屉中的Education后进入页面
个人教育经历概况

activity_education.xml

使用相对布局

<?xml version="1.0" encoding="utf-8"?>
<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: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.zonzi.myresume.EducationActivity">


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="45dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="小学"
            android:id="@+id/textView14"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="福田小学"
            android:id="@+id/textView15"
            android:layout_below="@+id/textView14"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="2002-2008"
            android:id="@+id/textView16"
            android:layout_below="@+id/textView15"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="初中"
            android:id="@+id/textView17"
            android:layout_below="@+id/textView16"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="43dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="深圳实验学校中学部"
            android:id="@+id/textView18"
            android:layout_below="@+id/textView17"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="2008-2011"
            android:id="@+id/textView19"
            android:layout_below="@+id/textView18"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="高中"
            android:id="@+id/textView20"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="深圳实验学校高中部"
            android:id="@+id/textView21"
            android:layout_below="@+id/textView20"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="2011-2014"
            android:id="@+id/textView22"
            android:layout_below="@+id/textView21"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="大学"
            android:id="@+id/textView23"
            android:layout_below="@+id/textView22"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="53dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="南京邮电大学"
            android:id="@+id/textView24"
            android:layout_below="@+id/textView23"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="2014-现在"
            android:id="@+id/textView25"
            android:layout_below="@+id/textView24"
            android:layout_centerHorizontal="true" />
    </RelativeLayout>
</RelativeLayout>

效果图
技术分享

ContactActivity

点击抽屉中的Contact后进入页面
个人联系方式
全部使用Design视图的拖拽完成,不贴代码
效果图
技术分享

SettingsActivity

直接使用AndroidStudio的模板建立, 点击右上角设置菜单后进入

总结

其实这次的项目并没有太多含金量,都是让我熟悉使用简单的模板,布局以及一些常用的属性。
出现的问题不是很多,因为步骤比较简单。

出现的bug

  1. Intent关键字首字母没大写
  2. 将图片按照eclipse的习惯放入以下路径(C:\Users\Zonzi\AndroidStudioProjects\MyResume\app\src\main\res\mipmap-xxxhdpi)后,却在.xml文件中如下引用:android:background=”@drawable/rvpcover” 正确引用应该是:android:background=”@mipmap/rvpcover”

视频演示:

自此开启了在CSDN的博客之旅,希望日后自己坚持下去,终有一日成为强人。
技术分享

移动应用技术开发大作业——Android平台个人简历

标签:

原文地址:http://blog.csdn.net/bas16/article/details/51383206

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!