刚开始有个任务就是做一个九宫格界面,后来有个任务就是实现点击每个格并跳转界面实现每个格的功能。下面我就介绍一下我是如何实现该功能的

首先写一下我的想法是:

登录成功后显示一个九宫格界面,每个九宫格的每一个都是一个功能模块,当点击每个模块时,就会跳转到相应的界面并实现该模块所具备的功能。

下面是以"综合实践管理系统"这个格来实现的,当我们点击该按钮时,他就会跳转到"学生综合实践模块积分申请表"这个界面然后我们通过下拉菜单选择自己想要申请的项目。然后点击"下一步"我们就跳转到补充信息这个界面了,实现上传照片还有补充信息这个功能界面。

第二步:跳转到下面这个界面

第三步点击下一步跳转到完善信息这个界面

点击加号上传你要加分的证明图片,这个照片可以调用相机照也可以是从相册中获取

点击从相册中获取会

下面就是我用到的控件及控件的用法。

 package com.itcast.test03;

 import java.util.ArrayList;
import java.util.HashMap;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast; public class StudentMainActivity extends Activity {
private GridView gridview; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_student_main);
gridview = (GridView)findViewById(R.id.gridView1);
ArrayList<HashMap<String,Object>> lstImageItem = new ArrayList<HashMap<String,Object>>();
for(int i = 1;i<20;i++){
HashMap<String,Object> map = new HashMap<String, Object>();
if(i==1){
map.put("ItemImage", R.drawable.ic_launcher02);
map.put("ItemText", "实践教学管理系统"); }else if(i==2){
map.put("ItemImage", R.drawable.ic_launcher06);
map.put("ItemText", "毕业设计管理系统"); }else if(i==3){
map.put("ItemImage", R.drawable.ic_launcher02);
map.put("ItemText", "开放实验管理系统"); }else if(i==4){
map.put("ItemImage", R.drawable.ic_launcher03);
map.put("ItemText", "实习实训管理系统"); }else if(i==5){
map.put("ItemImage", R.drawable.ic_launcher05);
map.put("ItemText", "班级事务管理系统"); }else if(i==6){
map.put("ItemImage", R.drawable.ic_launcher06);
map.put("ItemText", "综合实践管理系统"); }else if(i==7){
map.put("ItemImage", R.drawable.ic_launcher04);
map.put("ItemText", "其他事物2管理系统"); }else if(i==8){
map.put("ItemImage", R.drawable.ic_launcher08);
map.put("ItemText", "其他事物3管理系统"); }else if(i==9){
map.put("ItemImage", R.drawable.ic_launcher01);
map.put("ItemText", "其他事物4管理系统"); }else if(i==10){
map.put("ItemImage", R.drawable.ic_launcher02);
map.put("ItemText", "开放实验管理系统"); }else if(i==11){
map.put("ItemImage", R.drawable.ic_launcher03);
map.put("ItemText", "实习实训管理系统"); }else if(i==12){
map.put("ItemImage", R.drawable.ic_launcher05);
map.put("ItemText", "班级事务管理系统"); }else if(i==13){
map.put("ItemImage", R.drawable.ic_launcher06);
map.put("ItemText", "综合实践管理系统"); }else if(i==14){
map.put("ItemImage", R.drawable.ic_launcher04);
map.put("ItemText", "其他事物2管理系统"); }else if(i==15){
map.put("ItemImage", R.drawable.ic_launcher08);
map.put("ItemText", "其他事物3管理系统"); }else if(i==16){
map.put("ItemImage", R.drawable.ic_launcher01);
map.put("ItemText", "其他事物4管理系统"); }
lstImageItem.add(map);
}
SimpleAdapter saImageItems = new SimpleAdapter(this,
lstImageItem,R.layout.next_activity_student_main,
new String[]{"ItemImage","ItemText"},
new int[] {R.id.ItemImage,R.id.ItemText});
gridview.setAdapter(saImageItems);
gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
int index = arg2 + 1;// id是从0开始的,所以需要+1
if (index == 1) { Intent intent = new Intent();
intent.setClass(StudentMainActivity.this,
StudentNextMainActivity.class);
startActivity(intent);
}
if (index == 2) {
Intent intent = new Intent();
intent.setClass(StudentMainActivity.this,
StudentNextMainActivity.class);
startActivity(intent); } }
}); }
}
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" > <RelativeLayout
android:id="@+id/rl_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000000">
<TextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_margin="35dp"
android:textSize="20sp"
android:textColor="#FFFFFF"
android:text="欢迎登录软件学院管理系统"/>
</RelativeLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<GridView
android:id="@+id/gridView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="3" >
</GridView>
</LinearLayout>
</LinearLayout>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" > <ImageView
android:id="@+id/ItemImage"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"/> <TextView
android:id="@+id/ItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@+id/ItemImage"
android:layout_marginTop="24dp"
android:textColor="#000000"
android:textSize="12sp" /> </RelativeLayout>

以上是实现这个界面的代码

 package com.itcast.test03;

 import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import java.io.File;
import java.io.FileOutputStream;
import android.os.Environment;
import android.content.Intent;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
public class StudentNextMainActivity extends Activity
{
private Spinner projectsSpinner = null;
private Spinner kindsSpinner = null;
private Spinner examinesSpinner = null;
ArrayAdapter<String> projectsAdapter = null;
ArrayAdapter<String> kindsAdapter = null;
ArrayAdapter<String> examinesAdapter = null;
static int provincePosition = 3;
private String[] projects = new String[] {"科研训练","素质拓展","社会实践"};
private String[][] kinds = new String[][]
{
{ "项目类", "成果类", "学术活动"},
{ "专业素质", "综合素质"},
{ "无"}
}; private String[][][] examines = new String[][][]
{
{ //科研训练
{"主持或参加科研项目","校大学生创新基金重点项目","校大学生创新基金一般项目"},
{"获奖","著作","专利","论文"},
{"学术交流","学术讲座","课外读书"}
},
{ //素质拓展
{"学科竞赛(含挑战杯)","证书"},
{"开放实验","参加文体活动","组织活动"}
},
{ //社会实践
{"社会实践活动","社团活动","公益劳动","自主创业"}
}
}; @Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_student_next_main);
setSpinner();
}
public void pitcure(View view){
screenshot();
}
private void screenshot()
{
// 获取屏幕
View dView = getWindow().getDecorView();
dView.setDrawingCacheEnabled(true);
dView.buildDrawingCache();
Bitmap bmp = dView.getDrawingCache();
if (bmp != null)
{
try {
// 获取内置SD卡路径
String sdCardPath = Environment.getExternalStorageDirectory().getPath();
// 图片文件路径
String filePath = sdCardPath + File.separator + "screenshot.png"; File file = new File(filePath);
FileOutputStream os = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.PNG, 100, os);
os.flush();
os.close();
} catch (Exception e) {
}
}
}
public void next(View view){
Intent intent = new Intent(this,WriteMainActivity.class);
startActivity(intent);
} /*
* 设置下拉框
*/
private void setSpinner()
{
projectsSpinner = (Spinner)findViewById(R.id.spin_projects);
kindsSpinner = (Spinner)findViewById(R.id.spin_kinds);
examinesSpinner = (Spinner)findViewById(R.id.spin_examines); //绑定适配器和值
projectsAdapter = new ArrayAdapter<String>(StudentNextMainActivity.this,
android.R.layout.simple_spinner_item, projects);
projectsSpinner.setAdapter( projectsAdapter);
projectsSpinner.setSelection(2,true); //设置默认选中项,此处为默认选中第3个值 kindsAdapter = new ArrayAdapter<String>(StudentNextMainActivity.this,
android.R.layout.simple_spinner_item, kinds[2]);
kindsSpinner.setAdapter(kindsAdapter);
kindsSpinner.setSelection(0,true); //默认选中第0个
examinesAdapter = new ArrayAdapter<String>(StudentNextMainActivity.this,
android.R.layout.simple_spinner_item, examines[2][0]);
examinesSpinner.setAdapter(examinesAdapter);
examinesSpinner.setSelection(0, true);
projectsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
// 表示选项被改变的时候触发此方法,主要实现办法:动态改变地级适配器的绑定值
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3)
{ kindsAdapter = new ArrayAdapter<String>(
StudentNextMainActivity.this, android.R.layout.simple_spinner_item,kinds[position]);
kindsSpinner.setAdapter(kindsAdapter);
provincePosition = position; //记录当前省级序号,留给下面修改县级适配器时用
}
@Override
public void onNothingSelected(AdapterView<?> arg0)
{ } }); //种类下拉监听
kindsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int position, long arg3)
{
examinesAdapter = new ArrayAdapter<String>(StudentNextMainActivity.this,
android.R.layout.simple_spinner_item, examines[provincePosition][position]);
examinesSpinner.setAdapter(examinesAdapter);
}
@Override
public void onNothingSelected(AdapterView<?> arg0)
{ }
});
}
}
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#000000">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="24sp"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#FFFFFF"
android:text="学生综合实践模块积分申请表"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="8dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:orientation="vertical">
<Spinner
android:id="@+id/spin_projects"
android:layout_width="150dp"
android:layout_height="wrap_content" />
<Spinner
android:id="@+id/spin_kinds"
android:layout_width="200dp"
android:layout_height="wrap_content" />
<Spinner
android:id="@+id/spin_examines"
android:layout_width="300dp"
android:layout_height="wrap_content" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" > <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:onClick="pitcure"
android:background="#FFFFFF"
android:textColor="#000000"
android:text="截图" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="next"
android:background="#FFFFFF"
android:textColor="#000000"
android:text="下一步" /> </RelativeLayout> </LinearLayout>

以上代码是实现这个界面的

 package com.itcast.test03;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu; public class WriteMainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_write_main);
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.write_main, menu);
return true;
} }
 <?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="match_parent"
android:orientation="vertical"
android:padding="8dp" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#000000">
<Button
android:id="@+id/upload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#FFFFFF"
android:background="#000000"
android:textSize="18sp"
android:text="发送" />
</RelativeLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical" >
<EditText
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_margin="8dp"
android:gravity="left|top"
android:hint="填写你要申请的分数及其他信息......"
android:background="@null" >
</EditText>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/icon_addpic_unfocused" /> <GridView
android:id="@+id/noScrollgridview"
android:layout_width="290dp"
android:layout_height="350dp"
android:layout_marginLeft="5dp"
android:horizontalSpacing="3dp"
android:numColumns="4"
android:scrollbars="none"
android:verticalSpacing="5dp" >
</GridView> </LinearLayout>
</LinearLayout>

以上代码是实现这个界面的

Android九宫格界面实现点击每个格点击跳转界面的更多相关文章

  1. Android基础-系统架构分析,环境搭建,下载Android Studio,AndroidDevTools,Git使用教程,Github入门,界面设计介绍

    系统架构分析 Android体系结构 安卓结构有四大层,五个部分,Android分四层为: 应用层(Applications),应用框架层(Application Framework),系统运行层(L ...

  2. (转载)Android之有效防止按钮多次重复点击的方法(必看篇)

    为了防止测试妹子或者用户频繁点击某个按钮,导致程序在短时间内进行多次数据提交or数据处理,那到时候就比较坑了~ 那么如何有效避免这种情况的发生呢? 我的想法是,判断用户点击按钮间隔时间,如果间隔时间太 ...

  3. Easyui之datagrid实现点击单元格修改单元格背景颜色

    前段时间有个需求中有点击datagrid的单元格实现某种事件,调用datagrid的onclickCell这个方法很容易实现,但是体验不好啊,完全不知道自己刚才点击的是哪个单元格,然后就尝试单击单元格 ...

  4. android ListView的上部下拉刷新下部点击加载更多具体实现及拓展

    android ListView的上部下拉刷新下部点击加载更多具体实现及拓展 ListView下拉刷新,上拉自动加载更多 下拉刷新以及加载更多

  5. Android编程获取网络连接状态(3G/Wifi)及调用网络配置界面

    随着3G和Wifi的推广,越来越多的Android应用程序需要调用网络资源,检测网络连接状态也就成为网络应用程序所必备的功能. Android平台提供了ConnectivityManager  类,用 ...

  6. Android ListView的item背景色设置以及item点击无响应等相关问题

    Android ListView的item背景色设置以及item点击无响应等相关问题 在Android开发中,listview控件是非常常用的控件,在大多数情况下,大家都会改掉listview的ite ...

  7. 我的Android进阶之旅------>Android如何去除GridView的按下或点击选中后的背景效果

    今天用GridView做了一个界面,自己自定好了一个组件,并且设置好了点击和不点击组件时候的效果,但是运行的时候发现在我定义好的背景下面还有一层不知道哪儿来的背景,严重影响了我自定义的组件的效果. 后 ...

  8. UIView加入手势 然后UITableView 加入进这个View 导致UITableView 的单元格点击事件无效

    #import "ViewController.h" @interface ViewController ()<UITableViewDataSource,UITableVi ...

  9. Android studio关于点击事件后的页面跳转,选择完成后返回(onActivityResult)

    我这个人喜欢直接上代码,在代码中说明更方便,更直接. 首先在.xml中设置一个button按钮,和一个EditText框,并分别做好id号. 这里我以籍贯测试对象. <LinearLayout ...

随机推荐

  1. IIS 服务器下载apk文件报404错

    文件路径什么都对,可就是提示404错误,最后问题出在了IIS的MIME上,按照下面的办法即可解决. 1.在 IIS 管理器中,右键单击要为其添加 MIME 类型的网站或网站目录,单击"属性& ...

  2. Spring定时器,定时执行(quartz)

    这个定时器与继承了timertask的定时器不同的是,这个定时器是更强大的,可以指定每分的第n秒,每天的第n时,每周的.每年的.来定时运行这个定时器.那么下面来讲诉如何使用quartz定时器. spr ...

  3. SQL Server 2014里的缓存池扩展

    在今天的文章里我想谈下SQL Server 2014里引入的缓存池扩展(Buffer Pool Extensions).我们都知道,在SQL Server里,缓存池是主要的内存消耗者.当你从你存储里读 ...

  4. 【Android】Anroid5.0+新控件---酷炫标题栏的简单学习

    Android5.0+推出的新控件感觉特别酷,最近想模仿大神做个看图App出来,所以先把这些新控件用熟悉了. 新控件的介绍.使用等等网上相应的文章已经特别多了,题主也没那能力去写篇详解出来,本篇随笔记 ...

  5. jQuery Ajax实现下拉框无刷新联动

    HTML代码: @{ Layout = null; } @using DAL; @using System.Data; @{ AreaDal areaDal = new AreaDal(); stri ...

  6. iOS阶段学习第15天笔记(NSArray与NSMutableArray 数组)

    iOS学习(OC语言)知识点整理 一.OC中的数组 1)数组:也是一个对象,数组中存放的是对象的地址,可以存放任意类型对象的地址,只能是对象不能是具体的数值,数组是有序的,      可以存放重复的元 ...

  7. Hibernate---detached entity passed to persist一个解决方法

    1.查看id生成策略,2.查看是否是手动设置的id :3.查看实体对象映射配置是否正确. 例如: public Emplopes(String name, char gender) { super(n ...

  8. Vue从零开始(一)

    一.什么是Vue? Vue.js(读音 /vjuː/, 类似于 view) 是一套构建用户界面的 渐进式框架.与其他重量级框架不同的是,Vue 采用自底向上增量开发的设计.Vue 的核心库只关注视图层 ...

  9. mybatis There is no getter for property named 'xxxx

    mybatis There is no getter for property named 'xxxx 360反馈意见截图16230322799670.png http://blog.sina.com ...

  10. python学习笔记12 ----线程、进程

    进程和线程的概念 进程和线程是操作系统中两个很重要的概念,对于一般的程序,可能有若干个进程,每一个进程有若干个同时执行的线程.进程是资源管理的最小单位,线程是程序执行的最小单位(线程可共享同一进程里的 ...