Android学习第三天--listview方式一
2013-03-09 17:11
295 查看
第一种listview
xml文件中
在res下的values下添加下面的文件
主java文件中
xml文件中
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ListView android:id="@+id/listview1" android:entries="@array/info" android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout>
在res下的values下添加下面的文件
<?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="info"> <item>test1</item> <item>test1</item> <item>test1</item> <item>test1</item> <item>test1</item> <item>test1</item> <item>test1</item> <item>ltest1n</item> <item>test1</item> <item>test1</item> <item>test1</item> <item>test1</item> </string-array> </resources>
主java文件中
package cn.core.test; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; public class MainActivity extends Activity { ListView listView =null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); listView=(ListView)findViewById(R.id.listview1); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position,long arg3) { System.out.println(arg0.getItemAtPosition(position).toString()); } }); } }
相关文章推荐
- Android学习第三天--listview方式四
- Android学习第三天--listview方式二
- Android学习第三天--listview方式五
- Android学习第三天--listview方式三
- Android学习第三天--listview方式六
- Android学习第三天--listview方式七
- Android学习 —— 多种适配器方式实现ListView
- android学习记录3(数据存储的方式:sqlite、sp、存文件。listview简单使用)
- Android学习 —— 多种适配器方式实现ListView
- android ListView 与GridView 学习总结(五)
- Android(java)学习笔记132:ListViewProject案例(ListView + ArrayAdapter)
- 简单说说Android自定义view学习推荐的方式
- Android ListView嵌套ListView的实现方式
- Android学习系列(11)--App列表之拖拽ListView(下)
- Android ListView1 列表控件的学习
- Android学习之常见的布局方式--布局
- Android学习之Activity与Service进行通信的三种方式
- Android开源项目分包方式学习(eoe、oschina、github)
- Android学习之当ScrollView遭遇ListView(GridView)
- android abslistview item点击事件无响应的处理方式