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

首先写一下我的想法是:

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

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

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

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

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

点击从相册中获取会

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

 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. H5新特性websocket

    websocket也是html5的新增加内容之一,号称是下一代客户端/服务器异步通信办法,私以为虽然有点吹牛的成分,但是以后说不定能成为异步通信的半壁江山,至于取代ajax,我觉的应该不会. webs ...

  2. 解决matplotlib的中文问题

    matplotlib的强大无需我去言说,但它对使用中文的我来说却有一点瑕疵,那就是--在默认状态下,matplotlb无法在图表中使用中文. 在网上查找了一些资料,发现matplotlib本身是支持U ...

  3. SQL 聚合函数

    SQL聚合函数 MAX---最大值 MIN--最小值 AVG--平均值 SUM--求和 COUNT--记录的条数 EXample: --从MyStudent表中查询最大年龄,最小年龄,平均年龄,年龄的 ...

  4. LeetCode - 54. Spiral Matrix

    54. Spiral Matrix Problem's Link ------------------------------------------------------------------- ...

  5. img[src*="same"]{}

    假如你有一组图片,你想选择其中一些名字中带有same的图片,那么你就可以用这种写法,这里的意思就是选择所有正确路径下名字中带有same的图片文件. 譬如说:me_same.png,you_same.p ...

  6. GitHub简单教程

    Hello World程序是计算机编程中由来已久的惯例,这是一个当你在学习新事物的时候开始的一个简单的小练习.让我们开始GitHub的"Hello World". 你将学会: -  ...

  7. MySql基础整理

    http://hovertree.com/menu/mysql/ use abccs;select * from mytable2 limit 3,4;call sp_name1(1,@nn);sel ...

  8. c#如何采集需要登录的页面

    首先说明:代码片段是从网络获取,然后自己修改.我想好的东西应该拿来分享. 先说下原理:当我们采集页面的时候,如果被采集的网站需要登录才能采集.不管是基于Cookie还是基于Session,我们都会首先 ...

  9. Entity Framework 的简单介绍与实例

    1.下载与引用 a) 首先需要下载一个oracle clinent 12c 发行版(我这边下载的是发行版)并进行安装,下载内容如下图 B) 创建一个项目,通过Nuget引用  添加ODP.NET    ...

  10. webapi+entityframework分享

    1. webapi允许跨域的增删改查要在web.config中加入以下文字 <system.webServer> <validation validateIntegratedMode ...