如图中的界面,是不是listview只能布满全屏,不能小部分区域?我运行网上的例子后,根本就没有显示那个listview,可是代码中我明明绑定了它的。。我的意图是将mysql数据库里面的数据显示到这个view里面,数据库的连接啊什么的已经搞定,可以返回数据了,高手能否给个方法,怎么实现?不知道图片可以显示不,真个布局就是一个查询的文本框,按钮,下面添加一个listview,布局为绝对布局…xml代码见下面
<?xml version="1.0" encoding="UTF-8"?>
<AbsoluteLayout
android:id="@+id/AbsoluteLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TextView
android:layout_x="0dip"
android:layout_y="0dip"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/TextView01"
android:textSize="20dip"
android:text="通讯录"
>
</TextView>
<EditText
android:layout_x="30dip"
android:layout_y="40dip"
android:layout_height="wrap_content"
android:layout_width="180dip"
android:id="@+id/EditText01"
>
</EditText>
<Button
android:layout_x="225dip"
android:layout_y="40dip"
android:layout_height="40dp"
android:id="@+id/txlsearch"
android:layout_width="40dp"
android:background="@drawable/search">
</Button> <ListView
android:id="@+id/txllistView"
android:layout_width="280dp"
android:layout_height="295dp"
android:layout_x="20dp"
android:layout_y="110dp" >
</ListView>
</AbsoluteLayout>
<?xml version="1.0" encoding="UTF-8"?>
<AbsoluteLayout
android:id="@+id/AbsoluteLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TextView
android:layout_x="0dip"
android:layout_y="0dip"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/TextView01"
android:textSize="20dip"
android:text="通讯录"
>
</TextView>
<EditText
android:layout_x="30dip"
android:layout_y="40dip"
android:layout_height="wrap_content"
android:layout_width="180dip"
android:id="@+id/EditText01"
>
</EditText>
<Button
android:layout_x="225dip"
android:layout_y="40dip"
android:layout_height="40dp"
android:id="@+id/txlsearch"
android:layout_width="40dp"
android:background="@drawable/search">
</Button> <ListView
android:id="@+id/txllistView"
android:layout_width="280dp"
android:layout_height="295dp"
android:layout_x="20dp"
android:layout_y="110dp" >
</ListView>
</AbsoluteLayout>
解决方案 »
- android message
- android 搜索框无法关闭
- 请推荐一本Android底层的书
- 在cygwin下用NDK编译CPP工程时需要在.mk文件里面怎么写才能生成map文件,这个文件包含C++工程中所有函数的入口地址
- 华为U8150内核编译出错怎么解决
- 小问题
- android里service怎么会是在主线程里呢?
- 求ListView分页
- ant coverage出现的问题
- android studio 打开项目,没有目录
- [Android Robotium]修改apk签名后install, Run As Android JUnit Test出错
- android 视频播放问题。如何才能支持 多种视频格式。
建议楼主看下适配器和listview的关系,感觉楼主有可能没绑定适配器,或者绑定了getview布局与数据处理的不正确
super.onCreate(savedInstanceState);
setContentView(R.layout.tongxunlu);
//listView = new ListView( this );
ListView lv=(ListView)this.findViewById(R.id.txllistView);
lv.setAdapter( new ArrayAdapter<String>( this , android.R.layout.simple_expandable_list_item_1,getData()));
setContentView(lv);
} private List<String> getData(){
List<String> data = new ArrayList<String>();
data.add( "测试数据1" );
return data;
}
这句是用来做什么的,你打算用listview全屏吗