listView = new ListView(this); /* * ADAPTER将ARRAYLISTMAP中的数据以COPY_MAIN的形式输出,TITLE_ONE数据对应LIST_TITLE, * BODY_ONE数据对应到LIST_BODY */ SimpleAdapter adapter = new SimpleAdapter(this, MySQLite_3.arraylistmap, R.layout.copy_main, new String[] { MySQLite_3.TITLE_ONE, MySQLite_3.BODY_ONE }, new int[] { R.id.list_title, R.id.list_body });listView.setAdapter(adapter);你要修改的东西就是你自己的copy_main这个LAYOUT,你可以根据你自己的需求,修改每一个内部控件的大小以及位置的关系等。
定义一个text_contnet.xml文件,里面只放一个textview, ID为list_title在这个布局里面设置字体的大小, 在主activity里面 ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>(); HashMap<String, string> map; for (int i = 0; i < 你要显示的字条串数组的长度;i++) { map = = new HashMap<String, string>(); map.put("content",字符串数组名[i]); list.add(map);} SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.text_contnet, new String[] { "content"}, new int[] { R.id.list_title});listView.setAdapter(adapter);这样子就OK了
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="10px"
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>在adapter的getView里面用inflator加载这个layout,就可以达到改变item高度的目的。
View view = null;
LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
view = inflater.inflate(R.layout.row, null);
return view;
]从string中获得的只是数据内容,而不是layout。layout需要在/layout中去定义。
你改一下吧List的布局改成自己写,就容易控制了
直接在配置文件里控制样式,灵活
listView = new ListView(this);
/*
* ADAPTER将ARRAYLISTMAP中的数据以COPY_MAIN的形式输出,TITLE_ONE数据对应LIST_TITLE,
* BODY_ONE数据对应到LIST_BODY
*/
SimpleAdapter adapter = new SimpleAdapter(this,
MySQLite_3.arraylistmap, R.layout.copy_main, new String[] {
MySQLite_3.TITLE_ONE, MySQLite_3.BODY_ONE }, new int[] {
R.id.list_title, R.id.list_body });listView.setAdapter(adapter);你要修改的东西就是你自己的copy_main这个LAYOUT,你可以根据你自己的需求,修改每一个内部控件的大小以及位置的关系等。
在主activity里面
ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();
HashMap<String, string> map;
for (int i = 0; i < 你要显示的字条串数组的长度;i++)
{
map = = new HashMap<String, string>();
map.put("content",字符串数组名[i]);
list.add(map);}
SimpleAdapter adapter = new SimpleAdapter(this,
list, R.layout.text_contnet, new String[] {
"content"}, new int[] {
R.id.list_title});listView.setAdapter(adapter);这样子就OK了