SimpleAdapter那一節(jié)為什么我的列表項不能滾動?
對著老師的寫的:
<?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="horizontal">
? ? <ImageView
? ? ? ? android:id="@+id/info_img"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_marginLeft="3dp"
? ? ? ? android:src="@drawable/ic_launcher"
? ? ? ? />
? ? <TextView?
? ? ? ? android:id="@+id/text"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_toRightOf="@id/info_img"
? ? ? ? android:layout_marginTop="5dp"
? ? ? ? />
</LinearLayout>
package com.example.imooclistview;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class MainActivity extends Activity {
private ListView lv;
private SimpleAdapter sim_adapter;
private ArrayList<Map<String,Object>> dataList;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lv=(ListView)findViewById(R.id.listView);
dataList=new ArrayList<Map<String,Object>>();
sim_adapter=new SimpleAdapter(this, getData(), R.layout.info, new String[]{"img","text"}, new int[]{R.id.info_img,R.id.text});
lv.setAdapter(sim_adapter);
}
private ArrayList<Map<String,Object>> getData(){
for(int i=0;i<20;i++)
{
Map<String,Object> item=new HashMap<String,Object>();
item.put("img",R.drawable.ic_launcher);
item.put("text", "慕課網(wǎng)"+i);
dataList.add(item);
}
return dataList;
}
}
但是運(yùn)行的時候"慕課網(wǎng)8"以后的不能滾到屏幕中來是為什么:
2016-03-24
看看你的R.layout.main,里面有沒有把listview的滾動禁止。