1、首选是是Activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:id="@+id/tv"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="如下显示的listview列表"></TextView>
<ListView
android:id="@+id/lv"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
></ListView>
</LinearLayout>
2、需要SimpleDispatch中加载的布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="@+id/tt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "
/>
<TextView
android:id="@+id/tt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "
/>
<TextView
android:id="@+id/tt3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "
/>
</LinearLayout>
<TextView
android:id="@+id/tt4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "
/>
</LinearLayout>
3、在MainActivity中直接操作如下
package com.example.teststyle;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
public class MainActivity extends Activity {
// private ProgressBar progressBar;
// private Button bt;
private TextView tv;
private ListView lv;
private List<Map<String, Object>> listadda = new ArrayList<Map<String, Object>>(); //适配器中存储数据
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv=(TextView)findViewById(R.id.tv);
lv=(ListView)findViewById(R.id.lv); //listview控件
for(int i=0;i<4;i++){ //制造数据
Map<String,Object> map=new HashMap<String, Object>();
map.put("one", "发展人:");
map.put("two", "河南大学");
map.put("three", "成功交易");
map.put("four", "流水"+i);
listadda.add(map);
} //适配器中显示
SimpleAdapter simpleAdapter=new SimpleAdapter(this, listadda,R.layout.listviewone,
new String[]{"one","two","three","four"},new int[]{R.id.tt1,R.id.tt2,R.id.tt3,R.id.tt4});
lv.setAdapter(simpleAdapter);
}
}
--------------------------------------------------------------------------------------------------------
如果大家感觉有写的有帮助,请留句话,表示一下谢谢