其实做法很简单就是在你的listview的外部加一个HorizontalScrollView就行了
main.xml如下
<RelativeLayout 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" >
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listview"></ListView>
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
public class FirstListView extends Activity {
private List<String> items=new ArrayList<String>();
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
lv=(ListView)findViewById(R.id.listview);
for (int i = 0; i < 20; i++) {
items.add("fengluchun"+i);
lv.setAdapter(new MyAdapter());
class MyAdapter extends BaseAdapter{
public Object getItem(int position) {
public long getItemId(int position) {
LayoutInflater inflater=LayoutInflater.from(FirstListView.this);
public View getView(int position, View convertView, ViewGroup parent) {
view=inflater.inflate(R.layout.listformat, null);
TextView tv1=(TextView)view.findViewById(R.id.textView1);
TextView tv2=(TextView)view.findViewById(R.id.textView2);
TextView tv3=(TextView)view.findViewById(R.id.textView3);
tv1.setText(items.get(position));
tv2.setText(items.get(position));
tv3.setText(items.get(position));