当前位置:网站首页>GridView (implement table display icon)
GridView (implement table display icon)
2022-07-27 19:53:00 【Ashurol】
public class MainActivity extends ActionBarActivity implements OnItemClickListener{
private GridView gridview;
SimpleAdapter adapter;
int icon[]={R.drawable.caidan1,R.drawable.caidan2,R.drawable.caidan3,
R.drawable.caidan4,R.drawable.caidan5,R.drawable.caidan6,R.drawable.caidan7,R.drawable.caidan8};
String name[]={" Order "," Turntable "," Cancellation "," Set up "," to update "," Settle accounts "," Check Taiwan "," Merging "};
List<Map<String,Object>>listdata;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
gridview=(GridView) findViewById(R.id.gridView1);
// create data source
listdata=new ArrayList<Map<String,Object>>();
// Create adapter
adapter=new SimpleAdapter(this, getdata(), R.layout.item, new String[]{"image","text"}, new int[]{R.id.imageView1,R.id.textView1});
gridview.setAdapter(adapter);
// Register to listen
gridview.setOnItemClickListener(this);
}
public List<Map<String,Object>> getdata()
{
for(int i=0;i<icon.length;i++)
{
Map<String,Object> map=new HashMap<>();
map.put("image", icon[i]);
map.put("text", name[i]);
listdata.add(map);
}
return listdata;
}
@Override
public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {
// TODO Auto-generated method stub
//position Location slave 0 Start counting , Just in time with name[] Corresponding
Toast.makeText(this, " Click. "+name[position], Toast.LENGTH_SHORT).show();
}
}GridView Common properties of :
android:horizontalSpacing="10dp"// Column spacing
android:verticalSpacing="10dp"// row spacing
android:numColumns="3"// How many icons are displayed per line
item Layout file
<?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:background="#00000000"
android:gravity="center"
>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Text "
android:textColor="#ffffff" />
</LinearLayout>

边栏推荐
- Oppo released the first AR glasses and announced that it would invest 50billion in research and development in the next three years
- ArrayAdapter(数组适配器)与SimpleAdapter(简单适配器)
- SystemService(系统服务)
- Sqlife (database)
- Matplotlib(基本用法)
- Surpass Huawei? Ericsson has won more than 75 5g commercial contracts
- Matplotlib (basic usage)
- Oracle XE版安装与用户操作
- 【深度学习基础知识 - 43】优势比的概念
- Install Talib Library under Anaconda
猜你喜欢

JVM概述和内存管理(未完待续)

A low code development platform that brings high-value user experience

Come to sword finger offer 03. Repeated numbers in the array

Intent(有无返回值得跳转)

JS find all nodes sibling childNodes children
![[basic knowledge of deep learning - 37] solve the imbalance between positive and negative samples](/img/71/4052607951eb52862a6fd36366f216.png)
[basic knowledge of deep learning - 37] solve the imbalance between positive and negative samples

SQlife(数据库)

全局函数
![[RCTF2015]EasySQL-1|SQL注入](/img/69/aa1fc60ecf9a0702d35d876e8c3dda.png)
[RCTF2015]EasySQL-1|SQL注入
![[basic knowledge of deep learning - 45] distance calculation methods commonly used in machine learning](/img/6c/b0c2ea667ac361c13d38c8f5e6e5f1.png)
[basic knowledge of deep learning - 45] distance calculation methods commonly used in machine learning
随机推荐
被动收入:回归原始且安全的两种赚取方法
Intent(有无返回值得跳转)
JS 事件监听 鼠标 键盘 表单 页面 onclick onkeydown onChange
【深度学习基础知识 - 37】解决正负样本不均衡 Focal Loss
BroadcastReceiver(广播)
mysql学习录(三)多表查询、子查询、分页查询、case语句、单行函数
JS event listening mouse keyboard form page onclick onkeydown onchange
pytorch tensor的基本函数
容器总结
【深度学习基础知识 - 49】Kmeans
归一化(Normalization)和标准化(Standardization)
下放三星3J1传感器:代码暗示Pixel 7人脸识别安全性将大增
Adhering to the integration of software and hardware, one Hengke makes efforts to the intelligent educational robot market
[deep learning target detection series - 01] what is target detection
RadioGroup(单选框)
访问控制
【深度学习基础知识 - 47】贝叶斯网络与朴素贝叶斯
[basic knowledge of deep learning - 44] the method of realizing multiple classification by logistic regression
文件操作防护
【深度学习基础知识 - 40】CNN为什么比DNN在图像领域更具优势