package cn.nedu.math.ninebox;
import java.util.ArrayList;
import java.util.HashMap;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
public class NineBox extends Activity {
/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
//去除标题
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main_activity);
GridView gridview=(GridView)findViewById(R.id.gridview);
ArrayList<HashMap<String, Object>> lstImageItem = new ArrayList<HashMap<String, Object>>();
for(int i=1;i<10;i++)
{
HashMap<String, Object> map = new HashMap<String, Object>();
if(i==1){
map.put("ItemImage", R.drawable.g11);
map.put("ItemText", getResources().getString(R.string.gridview1));
}
if(i==2){
map.put("ItemImage", R.drawable.g12);
map.put("ItemText", getResources().getString(R.string.gridview2));
}
if(i==3){
map.put("ItemImage", R.drawable.g13);
map.put("ItemText", getResources().getString(R.string.gridview3));
}
if(i==4){
map.put("ItemImage", R.drawable.g14);
map.put("ItemText", getResources().getString(R.string.gridview4));
}
if(i==5){
map.put("ItemImage", R.drawable.g15);
map.put("ItemText", getResources().getString(R.string.gridview5));
}
if(i==6){
map.put("ItemImage", R.drawable.g16);
map.put("ItemText", getResources().getString(R.string.gridview6));
}
if(i==7){
map.put("ItemImage", R.drawable.g17);
map.put("ItemText", getResources().getString(R.string.gridview7));
}
if(i==8){
map.put("ItemImage", R.drawable.g18);
map.put("ItemText", getResources().getString(R.string.gridview8));
}
if(i==9){
map.put("ItemImage", R.drawable.g19);
map.put("ItemText", getResources().getString(R.string.gridview9));
}
lstImageItem.add(map);
}
SimpleAdapter saImageItems = new SimpleAdapter(this,
lstImageItem,
R.layout.grid_item,
new String[] {"ItemImage","ItemText"},
new int[] {R.id.ItemImage,R.id.ItemText});
gridview.setAdapter(saImageItems);
//设置九宫格的监听,并吐司汉字
gridview.setOnItemClickListener(new ItemClickListener());
}
class ItemClickListener implements OnItemClickListener
{
@SuppressWarnings("unchecked")
public void onItemClick(AdapterView<?> arg0,//The AdapterView where the click happened
View arg1,//The view within the AdapterView that was clicked
int arg2,//The position of the view in the adapter
long arg3//The row id of the item that was clicked
) {
HashMap<String, Object> item=(HashMap<String, Object>) arg0.getItemAtPosition(arg2);
if(item.get("ItemText").equals(getResources().getString(R.string.gridview1))){
Toast.makeText(NineBox.this, R.string.gridview1, Toast.LENGTH_LONG).show();
}
if(item.get("ItemText").equals(getResources().getString(R.string.gridview2))){
Toast.makeText(NineBox.this, R.string.gridview2, Toast.LENGTH_LONG).show();
}
if(item.get("ItemText").equals(getResources().getString(R.string.gridview3))){
Toast.makeText(NineBox.this, R.string.gridview3, Toast.LENGTH_LONG).show();
}
if(item.get("ItemText").equals(getResources().getString(R.string.gridview4))){
Toast.makeText(NineBox.this, R.string.gridview4, Toast.LENGTH_LONG).show();
}
if(item.get("ItemText").equals(getResources().getString(R.string.gridview5))){
Toast.makeText(NineBox.this, R.string.gridview5, Toast.LENGTH_LONG).show();
}
if(item.get("ItemText").equals(getResources().getString(R.string.gridview6))){
Toast.makeText(NineBox.this, R.string.gridview6, Toast.LENGTH_LONG).show();
}
if(item.get("ItemText").equals(getResources().getString(R.string.gridview7))){
Toast.makeText(NineBox.this, R.string.gridview7, Toast.LENGTH_LONG).show();
}
if(item.get("ItemText").equals(getResources().getString(R.string.gridview8))){
Toast.makeText(NineBox.this, R.string.gridview8, Toast.LENGTH_LONG).show();
}
if(item.get("ItemText").equals(getResources().getString(R.string.gridview9))){
Toast.makeText(NineBox.this, R.string.gridview9, Toast.LENGTH_LONG).show();
}
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
小程序 漂亮的九宫格源码.rar
共59个文件
png:32个
class:9个
xml:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 21 浏览量
2023-02-03
11:47:50
上传
评论
收藏 623KB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
小程序 漂亮的九宫格源码.rar (59个子文件)
Android 漂亮的九宫格源码
project.properties 563B
.classpath 364B
assets
src
cn
nedu
math
ninebox
NineBox.java 5KB
res
drawable-mdpi
icon.png 3KB
drawable-ldpi
icon.png 2KB
values
strings.xml 572B
layout
main.xml 382B
main_activity.xml 1KB
grid_item.xml 829B
drawable-hdpi
grid_selector_background.xml 1KB
g16.png 11KB
g13.png 18KB
g15.png 16KB
btn_icon_bg_pressed.png 751B
g19.png 11KB
btn_icon_bg_focused.png 776B
g14.png 17KB
g12.png 11KB
bg.png 19KB
top.png 14KB
g11.png 18KB
g18.png 8KB
g17.png 9KB
icon.png 4KB
bin
classes
cn
nedu
math
ninebox
NineBox.class 3KB
R$string.class 730B
R$layout.class 470B
NineBox$ItemClickListener.class 2KB
R$id.class 492B
BuildConfig.class 349B
R$attr.class 346B
R$drawable.class 836B
R.class 545B
resources.ap_ 144KB
NineBox.apk 150KB
jarlist.cache 119B
res
drawable-mdpi
icon.png 2KB
drawable-ldpi
icon.png 2KB
drawable-hdpi
g16.png 8KB
g13.png 16KB
g15.png 11KB
btn_icon_bg_pressed.png 747B
g19.png 9KB
btn_icon_bg_focused.png 883B
g14.png 15KB
g12.png 8KB
bg.png 19KB
top.png 14KB
g11.png 15KB
g18.png 5KB
g17.png 6KB
icon.png 4KB
classes.dex 7KB
default.properties 36B
.project 843B
AndroidManifest.xml 682B
gen
cn
nedu
math
ninebox
BuildConfig.java 162B
R.java 2KB
1-1209201149190-L.jpg 20KB
共 59 条
- 1
资源评论
大富大贵7
- 粉丝: 322
- 资源: 8868
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功