android GridView

时间:2018-07-28 05:16:26
【文件属性】:

文件名称:android GridView

文件大小:1.17MB

文件格式:ZIP

更新时间:2018-07-28 05:16:26

GridView android

package com.example.gridview; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.widget.GridView; import android.widget.SimpleAdapter; public class MainActivity extends Activity { private GridView gview; private List>data_list; private SimpleAdapter sim_adapter; private int[] icon={R.drawable.ic_launcher,R.drawable.ic_launcher,R.drawable.ic_launcher,R.drawable.ic_launcher, R.drawable.ic_launcher,R.drawable.ic_launcher,R.drawable.ic_launcher,R.drawable.ic_launcher, R.drawable.ic_launcher,R.drawable.ic_launcher,R.drawable.ic_launcher,R.drawable.ic_launcher, }; private String[] iconName={"通讯录","通讯录","通讯录","通讯录" ,"通讯录","通讯录","通讯录","通讯录" ,"通讯录","通讯录","通讯录","通讯录"}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); gview=(GridView) findViewById(R.id.gview); //新建List data_list=new ArrayList>(); //获取数据 getData(); //新建适配器 String [] from={"image","text"}; int [] to={R.id.image,R.id.text}; sim_adapter = new SimpleAdapter(this, data_list, R.layout.item, from, to); //配置适配器 gview.setAdapter(sim_adapter); } public List> getData(){ //cion和iconName的长度是相同的,这里任选其一都可以 for(int i=0;i map = new HashMap(); map.put("image", icon[i]); map.put("text", iconName[i]); data_list.add(map); } return data_list; } }


【文件预览】:
GridView
----.project(844B)
----project.properties(563B)
----src()
--------com()
----AndroidManifest.xml(882B)
----res()
--------drawable-ldpi()
--------drawable-hdpi()
--------values-v11()
--------menu()
--------drawable-mdpi()
--------layout()
--------values-sw600dp()
--------drawable-xxhdpi()
--------drawable-xhdpi()
--------values()
--------values-sw720dp-land()
--------values-v14()
----.settings()
--------org.eclipse.jdt.core.prefs(177B)
----assets()
----gen()
--------com()
----libs()
--------android-support-v4.jar(473KB)
----.classpath(475B)
----proguard-project.txt(781B)
----ic_launcher-web.png(50KB)
----bin()
--------resources.ap_(41KB)
--------GridView.apk(229KB)
--------classes()
--------AndroidManifest.xml(882B)
--------dexedLibs()
--------jarlist.cache(120B)
--------res()
--------classes.dex(543KB)

网友评论