android控件之ListView(一)
来源:互联网 发布:物流配货软件 编辑:程序博客网 时间:2024/04/26 08:32
main.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Button android:id="@+id/myButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="点击" /> <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:drawSelectorOnTop="true" /></LinearLayout>
android:drawSelectorOnTop="true" 点击某一条记录,颜色会显示在最上面,记录上的文字被遮住,所以点击文字不放,文字就看不到
android:drawSelectorOnTop="false" 点击某条记录不放,颜色会在记录的后面,成为背景色,但是记录内容的文字是可见的
MytestActivity.java
package com.android.demo;import android.app.ListActivity;import android.os.Bundle;import android.view.View;import android.widget.ArrayAdapter;import android.widget.Button;import android.widget.ListView;public class MytestActivity extends ListActivity {Button MyButton;String[] items={"One", "Two", "Three", "Four", "Five"}; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); MyButton = (Button)findViewById(R.id.myButton); setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, items)); }@Overrideprotected void onListItemClick(ListView l, View v, int position, long id) {// TODO Auto-generated method stubMyButton.setText(items[position]);super.onListItemClick(l, v, position, id);} }结果如图
- android控件之ListView(一)
- Android控件之ListView探究一
- Android控件之ListView探究一
- Android控件之ListView探究一
- Android控件之ListView(一)
- Android控件之ListView(一)
- Android控件之ListView(一)
- Android常用控件之ListView(一)
- Android 控件之ListView
- Android控件之ListView
- Android控件之ListView
- android控件之ListView
- Android控件之ListView
- Android控件之ListView
- Android控件之ListView
- Android控件之ListView
- Android之ListView控件
- Android控件之ListView
- 关于AS3代码异步执行问题的个人常用解决办法
- Java编程最差实践
- 怎样把工作和升职大计结合起来 http://www.people.com.cn/GB/shenghuo/78/113/20020801/790056.html
- ITRON基础介绍
- 回头看看她的日记, 我哭了。 我曾经说过她从来不知道对我好,现在我知道了,她都藏在心里
- android控件之ListView(一)
- 实现一个具有百度文库文档转换功能的工具类
- 初学Java,单例模式(十五)
- 本地推送
- css选择器
- 求二叉树节点的最大距离
- IBM AIX 下shell获取昨天的日期
- LAMP-系统设置-sshd设置
- getopt_long的使用