当前位置:网站首页>Listview control
Listview control
2022-06-26 07:50:00 【Don't hit me, it hurts!】
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.sdau.windseeker.listview.MainActivity"> <ListView android:id="@+id/list_view" android:layout_width="match_parent" android:layout_height="match_parent"/></LinearLayout>
public class MainActivity extends AppCompatActivity { private String[] data={ "apple","banana","Orange","Pear","watermelon","Mango", "Good","cat","dog","Grape","cxbg","cdstgdr","d","srw","swws","qweter","dfaw","aew3rwa","wee","wrwqww"}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ArrayAdapter<String> adapter=new ArrayAdapter<String>( MainActivity.this,android.R.layout.simple_list_item_1,data); ListView listView=(ListView) findViewById(R.id.list_view); listView.setAdapter(adapter); } }Elements in an array cannot be passed directly to ListView, You need an adapter to do .Finally, you need to call ListView Of setAdapter() Method , Pass the constructed adapter object in .
边栏推荐
- Encapsulating ranging and surface class based on leaflet
- Open a file at line with'filename:line'syntax - open a file at line with'filename:line' syntax
- Seven important reasons for responsive Web Design
- I want to create SQL data (storage structure)
- The 9th zero code training camp is officially open for registration! (Beijing, Shanghai, Guangzhou and Shenzhen)
- Chapter II (summary)
- 手机开户哪个证券公司佣金最低?网上开户是否安全么?
- Uniapp scrolling load (one page, multiple lists)
- PCB miscellaneous mail
- I3wm get window class
猜你喜欢

A bold sounding and awesome operation - remake a Netflix

What is the five levels of cultivation of MES management system

Important reference indicators for data center disaster recovery: RTO and RPO

Children play games (greed, prefix and) - Niuke winter vacation training camp

Opencv鼠标事件+界面交互之绘制矩形多边形选取感兴趣区域ROI

Apache inlong graduated as a top-level project with a million billion level data stream processing capability!

The first screen time, you said you optimized it, then you calculated it and showed it to me!

What are the characteristics of digital factory in construction industry

This article will take you to learn in detail what is FTTH

B站增量数据湖探索与实践
随机推荐
Jemter 壓力測試 -基礎請求-【教學篇】
D do not assign references to non domain parameters
指南针炒股软件开户是合法的吗?安全吗
Detach an entity from jpa/ejb3 persistence context
[issue 22] sheen cloud platform one side & two sides
Summary of domestic database examination data (continuously updated)
项目管理学习
Encapsulating ranging and surface class based on leaflet
Pic 10B parsing
Minor problems in importing D
个人用指南针软件买股票安全吗?怎么炒股买股票呢
Redis (4) -- Talking about integer set
Redis(5)----浅谈压缩列表
The first multi platform webcast of 2021ccf award ceremony pays tribute to the winners! CCF outstanding engineer
My colleague asked a question I never thought about. Why did kubernetes' superfluous' launch the static pod concept?
B站增量数据湖探索与实践
Okhttp3 source code explanation (IV) cache strategy, disadvantages of Android mixed development
Jemter stress test - Basic request - [teaching]
Gavin teacher's insight on transformer live class - multi state transition of financial BOT and rasa interactive behavior analysis of Rasa project (52)
有序排列