Android 无法滚动片段内的ListView
我的布局如下: 黄色背景是存储在片段中的列表项 以下是活动的代码:Android 无法滚动片段内的ListView,android,android-fragments,Android,Android Fragments,我的布局如下: 黄色背景是存储在片段中的列表项 以下是活动的代码: <fragment android:layout_width="140dp" android:layout_height="100dp" android:layout_below="@+id/block" class="fragments.Demo"/> 片段代码: public class Demo extends ListFragment{
<fragment android:layout_width="140dp"
android:layout_height="100dp"
android:layout_below="@+id/block"
class="fragments.Demo"/>
片段代码:
public class Demo extends ListFragment{
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
"Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
"Linux", "OS/2" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.getActivity().getApplicationContext(), R.layout.list_item_bank, R.id.list_item_bank_name, values);
setListAdapter(adapter);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.transaction_list_fragment, null);
}
}
公共类演示扩展了ListFragment{
@凌驾
已创建ActivityState上的公共无效(Bundle savedInstanceState){
super.onActivityCreated(savedInstanceState);
字符串[]值=新字符串[]{“Android”、“iPhone”、“WindowsMobile”,
“黑莓”、“WebOS”、“Ubuntu”、“Windows7”、“Max OS X”,
“Linux”、“OS/2”};
ArrayAdapter=新的ArrayAdapter(this.getActivity().getApplicationContext(),R.layout.list\u item\u bank,R.id.list\u item\u bank\u name,value);
setListAdapter(适配器);
}
CreateView上的公共视图(布局、充气机、视图组容器、捆绑包保存状态){
返回充气器。充气(R.layout.transaction\u list\u片段,空);
}
}
R.layout.list\u项目\u银行:
<?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="wrap_content"
android:background="#ffee00"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<TextView android:id="@+id/list_item_bank_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:text=""
android:textColor="@color/abs__primary_text_holo_light"
android:textSize="18sp">
</TextView>
</LinearLayout>
问题是:我无法从主活动滚动列表视图。怎么了?哇!在我看来,我发现了问题所在。
我的ListFragment在滚动视图中。如果我用线性布局替换滚动视图,一切都正常 你能发布你的listView布局吗?